这个问题已经在这里有了答案: > How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result 1个
我的以下代码在我的本地主机服务器上工作.当我将其托管到实际服务器时,尽管建立了连接,但查询无法正常工作.
输出是
“result problem”
<?php
include_once 'db_connect.php';
class test{
public function test1(){
$db_connect = new db_connect();
$con = $db_connect->connect();
if(!$con){
echo "connection fail";
}else{
$sql = "select * from tbl_admin where name='abc' ";
$query = mysqli_query($con,$sql);
if(!$query){
echo "result problem";
}else{
$result = mysqli_fetch_array($query);
echo $result['ad_tp'];
}
}
}
}
$t = new test();
$t->test1();
解决方法:
更换
echo "result problem";
与
printf("Errormessage: %s\n", mysqli_error($link));
这将使您确切了解为什么不执行查询.