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

后端 未结 5 2069
夕颜
夕颜 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 17:49

    public function connectDB($DBServer, $DBUser, $DBPass, $DBName) {
                global $con;
                $con = new mysqli($DBServer, $DBUser, $DBPass, $DBName) or die ("Error occured");
                return $con;
    

    and then pass $con in all the functions that you define or run wherever.

提交回复
热议问题