I have problem with PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result

Discussion in 'MySQL' started by leutrimraifi, May 24, 2017.

  1. #1
    Please can you help me what i need to do?
    nonstop i have that error on my server

    PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/mydomain.com/public_html/includes/db_mysqli.php on line$n line 85, referer: http://m.facebook.com

    Here is db_mysqli.php file

    <?php
    class Database{
       private $con = false;
      private $conect = "";
       private $result = array();
      private $query = "";
       public function connect(){
    
         if(!$this->con){
           $this->conect = new mysqli( _host, _user, _pass, _base );
           $this->conect->set_charset("utf8");
              
      if($this->conect->connect_errno > 0){
      array_push($this->result,$this->conect->connect_error);
      return false;
      }else{
      $this->con = true;
      return true;
      }
    
      }else{ 
      return true;
      }   
       }
    
      public function close(){
         if($this->con){
    
           if($this->conect->close()){
    
             $this->con = false;
    
             return true;
           }else{
             return false;
           }
         }
      }
    
       public function query($query){
         $query = $this->conect->query($query);
         return $query;
       }
    
       public function fetch_array($sql){
         $array = mysqli_fetch_array($sql);
         return $array;
       }  
    
       private function tableExists($table){
    
         $tablesInDb = $this->conect->query('SHOW TABLES FROM '._base.' LIKE "'.$table.'"');
    
      if($tablesInDb){
         if($tablesInDb->num_rows == 1){
      return true;
      }else{
         array_push($this->result,$table." does not exist in this database");
      return false;
      }
      }
      }
    
       public function num_rows($query)
       {
         return mysqli_num_rows($query);
       }
    }
    ?>
    PHP:
     
    Last edited by a moderator: May 24, 2017
    leutrimraifi, May 24, 2017 IP
  2. Blank ™

    Blank ™ Well-Known Member

    Messages:
    223
    Likes Received:
    18
    Best Answers:
    6
    Trophy Points:
    110
    #2
    Query is returning false instead of whatever you wanted it to return. Use error reporting (http://php.net/manual/en/mysqli.error.php) to find out why.
     
    Blank ™, May 24, 2017 IP