开发者

How can i tell if a MySQL query returned nothing in PHP?

开发者 https://www.devze.com 2022-12-15 02:21 出处:网络
I\'m using PHP5 and M开发者_如何学编程ySQL. I\'m using mysql_...() functions.if (mysql_num_rows($query_identifier) == 0)

I'm using PHP5 and M开发者_如何学编程ySQL. I'm using mysql_...() functions.


if (mysql_num_rows($query_identifier) == 0)
  echo "Query returned 0 rows";

Additionally, mysql_query() returns false in case of an error.

Manual: MySQL functions in PHP


If you are using mysqli_ functions, you can call $stmt->num_rows(). But only after calling $stmt->store_result() to ensure all the rows have been returned.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号