How can i tell if a MySQL query returned nothing in PHP?
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.
精彩评论