Because mysql_num_rows returns false if there are no rows returned, would it be best to do:
$query = mysql_query("SELECT id FROM table WHERE something = 'this'");
$result = mysql_num_rows($query);
if ($result) { }
Or should I do:
if ($result >= 1) { }
The proper one
however, you could do this easier, without checking
Please. Give your variables proper names
Count will return a value, and you cannot count and then call mysql_num_rows. It is either one of the other.
You could do
If alternatively you can do the query as:
It doesn't return
false
if no rows are returned, it returnsfalse
in the case of an error. You can handle that this way:The proper way would be using PDO instead of the ancient
mysql_*
functions:I think honestly that
is more appropriate.