Fatal error: Call to a member function query() on a non object

后端 未结 5 2061
夕颜
夕颜 2020-12-21 17:11

I\'ve got this error:

Fatal error: Call to a member function query() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 8

The line is

5条回答
  •  天命终不由人
    2020-12-21 18:10

    function check_login($user,$pw,&$result){
        global $mysqli;
        $res = $mysqli->query("SELECT * FROM user WHERE user='$user' and password='$pw'");
        $cont = 0;
        while($row = $re[...]
    

    Mind the "global". This puts the var in the scope of your method. This is a quick and dirty solution, but will work in this case.

提交回复
热议问题