如果查询为空,mysqli

编程入门 行业动态 更新时间:2024-10-26 06:33:19
本文介绍了如果查询为空,mysqli_query返回什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在搜索条件,查看是否$result=mysqli_query($dbconnect,$someQuery);

if($result==false)或if($result==null),但是它不响应布尔值作为比较值.尽管如果满足条件,则会调用if($result==true)条件.

这是我的查询

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

什么条件检查mysql查询是否失败或什么都不返回?

解决方案

mysql_query()如果存在任何查询错误,则始终返回false.对于成功的查询,它不会返回false.不为空,它将返回mysqli_result()对象.

请此处. /p>

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?

解决方案

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 ..:)

更多推荐

如果查询为空,mysqli

本文发布于:2023-10-25 14:27:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1527216.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为空   mysqli

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!