0

hi i have problem with my library i want to select data from database then i want to insert again with that selected data

here my code

class Sms  {
     function __construct() {
       $ci = &get_instance();
       }
   function send($no,$msg,$username)
   {            
            $ci = &get_instance();
            $ci->load->model('log_model');
            $host = "127.0.0.1";
            $port = "8800";
            $username = "admin";
            $password = "";
            $hp = $this->db->query('SELECT hp FROM t_akun');


            $fp = fsockopen($host, $port, $errno, $errstr);
            if (!$fp) {

                "errno: $errno \n";
                echo "errstr: $errstr\n";
                return $result;
            }

            fwrite($fp, "GET /?Phone=".$no."&Text=" . rawurlencode($msg) . " HTTP/1.0\n");
            if ($username != "") {
                $auth = $username . ":" . $password;
                $auth = base64_encode($auth);
                fwrite($fp, "Authorization: Basic " . $auth . "\n");
            }

            fwrite($fp, "\n");

            $res = "";

            while(!feof($fp)) {
               $res .= fread($fp,1);
            }
            fclose($fp);

            $nolog = explode(',',$no);

            date_default_timezone_set('Asia/Jakarta');
            $now = date("Y-m-d H:i:s");
            foreach($nolog as $row)
            {
            $data= array(
                'username'=>$username,
                'hp'=>$hp,
                'act'=>'Send',
                'd_log'=>$now
                );
             $ci->log_model->add_log($data);
            }
            if($res)
            {           
                return $no;
            } 
    }  
}

thats code was error

but if $hp change into code like this it works

$ci = &get_instance();
            $ci->load->model('log_model');
            $host = "127.0.0.1";
            $port = "8800";
            $username = "admin";
            $password = "";
            $hp = "12345678";

pls help me :(

1 Answer 1

1

First, you must create a PHP page in View directory of CodeIgniter, in which a form is created using CodeIgniter’s syntax. Second, you have to create class in Controller directory, in which the above PHP page(view) is loaded, applying validation over form fields and respective model is loaded. Third, for database connectivity in your application, a class is created in Model directory with database insert function.

Cehek the web site it may be beneficial. http://www.formget.com/insert-data-into-database-using-codeigniter/

Sign up to request clarification or add additional context in comments.

1 Comment

i have page in view directory, i just need solution, how to select data on database then insert that selected data again, im using variable $hp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.