This question already has an answer here:
mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?

(1 个回答)


4年前关闭。




我的以下代码在我的本地主机服务器上运行。当我将它托管到实际服务器时,虽然建立了连接,但查询不起作用。
输出是


<?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));

这将使您准确了解查询未执行的原因。

关于PHP mysqli_query 在实际托管服务器上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33341702/

10-12 12:52
查看更多