Re: mysql if empty
| From: | Paul Novitski | Date: | Mon, 09 Apr 2007 21:58:55 +0000 |
| Subject: | Re: mysql if empty | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252374@lists.php.net to get a copy of this message | ||
At 4/9/2007 02:18 PM, chris@aquanuke.com 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