Page 1 of 1
empty()
Posted: Wed Sep 28, 2005 5:41 pm
by Jim_Bo
Hi,
Should this work?
Doesnt seem to echo the result if the query is empty
?
Thanks
Posted: Wed Sep 28, 2005 5:49 pm
by Maugrim_The_Reaper
See the manual...
empty() will return true if the value is one of:
NULL
0
'' (empty string)
false (boolean)
Posted: Wed Sep 28, 2005 6:05 pm
by Jenk
mysql_query() will only return FALSE if there is an error.
If there are no rows returned, it will still return a result set, it'll just have no rows in it.
To check the number of rows returned in a result, use:
Code: Select all
<?php
$result = mysql_query($query);
if (mysql_num_rows($result) < 1) {
die('No rows returned!');
}
?>
or similar.