PDA

View Full Version : empty set


fraknot
07-29-2003, 09:54 PM
its me again

how do i validate if a 'mysql_query' statement returns an 'empty set'?

this not works.........


$result=mysql_query($query,$con);
if(!$result)
{
echo "Error";
}

raf
07-29-2003, 10:15 PM
It doesn't work because mysql_query() only returns False if there is an error. An empty recordset is not an error.

You can use mysql_num_rows() to get the number of returned records.

$result=@mysql_query($query,$con)
or die("Your query prodced the following error: " . mysql_error());
$numrecords= mysql_num_rows($result);

if ($numrecords ==0) {
echo "No records meet the coditions blabla";
}
else {
your code
}

fraknot
07-30-2003, 03:42 PM
thanx raf

raf
07-30-2003, 04:58 PM
No problem:thumbsup: