what mysqli_query returns if query was empty

2019-09-22 13:37发布

I am making a search condition where i see if the $result=mysqli_query($dbconnect,$someQuery);

if($result==false) orif($result==null) but it doesn't respond to a boolean as a compared value. although if the condition is satisfied, the if($result==true) condition is called.

this is my query

    $someQuery="select * from books where bookid = '$id'";

what condition checks if the mysql query failed or returned nothing?

标签: php mysqli
3条回答
▲ chillily
2楼-- · 2019-09-22 13:54

Like @Avinash Babu sait mysql_query allways return false if there is something wrong with the query....I would suggest you try to check if the query was successfully or not like this:

if(!result){
 echo 'Mayday We have a problem';
}
查看更多
仙女界的扛把子
3楼-- · 2019-09-22 14:03

mysql_query() returns false always if there is any query error.For a successful queries it wont return false..The return value will be true and if the row is not empty it will return the mysqli_result() object.

Please have a look here.It might help more ..:)

查看更多
够拽才男人
4楼-- · 2019-09-22 14:17

Please search for it on google, this should help you http://php.net/manual/en/mysqli.query.php by the way, mysqli_query returns FALSE if the statement fails, or a mysqli_result object which can used to associate arrays or other stuff

reference: http://php.net/manual/en/mysqli.query.php as written before

查看更多
登录 后发表回答