mysql_connect function has been removed from php7. If you are using PHP7 you should use mysqli_connect instead http://php.net/manual/es/function.mysqli-connect.php. Same for mysql_query and all the mysql_* functions. You should use the mysqli_* functions.
Nov 25, 2018
6
Level 27
crodjob php script
Hello,
I am trying to create crobjob php script. and I get this error message:
Fatal error: Uncaught Error: Call to undefined function msql_connect() in C:\xampp\htdocs\ids-api\public\cronjob_script.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\ids-api\public\cronjob_script.php on line 5
I wonder why?
I thought msql_connect() would works for all php version. http://id1.php.net/manual/en/function.msql-query.php
cronjob_script.php
$link = msql_connect("dbserver") or die("unable to connect to msql server: " . msql_error());
msql_select_db("ids", $link) or die("unable to select database 'db': " . msql_error());
$report = msql_query("SELECT * FROM tb_r_solusiorder LEFT JOIN tb_m_biller ON tb_r_solusiorder.billerid = tb_m_biller.biller_id LEFT JOIN tb_m_user_solusi ON tb_m_user_solusi.MobilePhone = tb_r_solusiorder.MobilePhone");
$report_string = "";
$url = "http://localhost/ids-api/public/api/list-report";
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($report));
curl_setopt($ch,CURLOPT_POSTFIELDS, $report_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
echo "<pre>";
print_r($result);
echo "</pre>";
Level 50
@DAVY_YG - mysqli_connect syntax is different than mysql_connect. You should call the function like this.
mysqli_connect('localhost', 'user', 'password', 'database');
Please or to participate in this conversation.