我有改變的mysql_query聲明的mysqli如下如何使用mysqli查詢而不是mysql_query沒有得到致命錯誤?
$sqlordlod = "SELECT * FROM order_list
WHERE user_id = '$user_id'
ORDER by order_id LIMIT $offset, $rec_limit ";
$result = $mysqli->query($sqlordlod);
$countrw = $result->num_rows;
echo $countrw;
數據庫連接文件
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_database);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
反正跟着我做了上述修改建議,但得到:
Warning: mysqli::query() expects parameter 1 to be string, object given in /Applications/XAMPP/xamppfiles/htdocs/_/globe/ru/profile.php on line 487
Fatal error: Call to a member function fetch_array() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/_/globe/ru/profile.php on line 487
下面是線487
while($rowld = $mysqli->query($result)->fetch_array())
{
// flip flop controling the tr class to change the color
if ($classchk ==3){
$classchk =1;
}
if ($classchk ==2){
$classname = "alt";
}else{
$classname = "none";
}
你能提供更多的代碼,所以我可以理解你想達到什麼嗎? – vooD