mysql - Fatal error: Call to a member function num_rows() on boolean in C:\xamp\htdocs\project24\system\database\DB_driver.php on line 768 -


dear getting error when trying create table through migration. getting following error:

fatal error: call member function num_rows() on boolean   in c:\xamp\htdocs\project24\system\database\db_driver.php on line 768 

my code is:

    if ($query->num_rows() > 0)     {         foreach ($query->result_array() $row)         {             if (isset($row['table_name']))             {                 $retval[] = $row['table_name'];             }             else             {                 $retval[] = array_shift($row);             }         }     }     $this->data_cache['table_names'] = $retval;     $ex=$this->data_cache['table_names'];     return $ex; } 

line number 768

enter image description here

please me out error

i'll suppose $query result of sending query , getting response. i'll explain more appropiate var names:

if($result = connection()->query($query)) $rs = mysqli_fetch_array($result); 

ok, @ point have first row on $rs, doesn't matter if $rs void here. remember if use create sentence, mysql engine return void (0 cols) result, php can take true (if table created) or false (if not), it's boolean. in case make select on there, , want in loop, follow this:

while ($rs != ''){  //do $rs[index];  $rs = mysqli_fetch_array($result); //to take next row } connection()-close(); 

hope helps. cheers!


Comments