Hello,
I would really appreciate any help! and thanks in advance!
Is there any way to distinguish if a query result produces no records matching your criteria as against if an error occurred if an error is running?
I normally use the following format when I query a database:
$query = "SELECT .... FROM .... WHERE ....";
$result = mysql_query($query);
if (!$result)
{
// either there are no records to match the criteria or, a
database error occurred
echo ("either error or no records");
}
The problem is that I can't distinguish between a "no matching records" or a database error.
Should I use a mysql_num_rows instead? Is the following correct?
$numrows = mysql_num_rows($result)
if (!$numrows)
{ //means that there was an error running query??? }
else
{ //returns number of matching records, including zero }
Thanks!!
😕