Re: mysql if empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 4/9/2007 02:18 PM, chris@xxxxxxxxxxxx wrote:
If I search for something in mysql that returns an empty result I cant get it to return "No result found" always returns "Found" even though the recoed does not exist...

$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";


$result tells you whether or not the query executed successfully. If ($result === FALSE), look to mysql_error() for a description of the problem. Otherwise, $result is the handle to the query's result.

A successful (non-error-producing) query can return zero rows of data. A perfect example is when you check a user table to make sure a username isn't already taken before creating a new record.

Read this page again carefully:
http://php.net/mysql_query

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux