2021年1月22日星期五

MySQL query handle undefined

I have the following code, which works fine. Queries are executed, everything is OK. BUT I am getting a error from PHP: Notice: Undefined variable: handle in ..../class.database.php on line 43.

I can not figure out why that is happening.

(Line 43 points to the line of code marked below)

function __construct($hostname, $user, $pass, $databasename)  {      $this->$handle = mysqli_connect($hostname, $user, $pass);      if(!$this->$handle)      {          $this->seterror();          return false;      }      $handle = mysqli_select_db($this->$handle, $databasename);      if(!$handle)      {          $this->seterror();          return false;      }      return true;  }    function query($text)  {      $result = mysqli_query($this->$handle,$text); // LINE 43      if(!$result)      {          $this->seterror();          $this->geterror(); // temp          return false;      }      return $result;  }  
https://stackoverflow.com/questions/65854548/mysql-query-handle-undefined January 23, 2021 at 08:30AM

没有评论:

发表评论