mysqli - PHP: Trying to get property of non-object -
i working on function, returns whether table exists or not.
but notices:
notice: trying property of non-object [...] on line 10
in
1 function table_exists($table) { 2 3 // database 4 global $mysqli; 5 6 // tables named $table 7 $result = $mysqli->query("show tables $table"); 8 9 // if result has more 0 rows 10 if($result->num_rows > 0) { 11 return true; 12 } else { 13 return false; 14 } 15 }
the $mysqli var set this:
$mysqli = new mysqli(mysqli_host, mysqli_user, mysqli_password, mysqli_database);
how solve that?
your sql syntax wrong. check value of variable $table. should have like
show tables "%"
Comments
Post a Comment