Re[2]: [PHP] [php] if $sql has returned something
| From: | Richard Davey | Date: | Wed, 25 Feb 2004 18:00:44 +0000 |
| Subject: | Re[2]: [PHP] [php] if $sql has returned something | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-178865@lists.php.net to get a copy of this message | ||
Hello John,
Wednesday, February 25, 2004, 5:53:13 PM, you wrote:
JTJ> Here is my code. $sql works correctly, but am not sure I did this line correct:
JTJ> $glquery = mysql_query($sql);
JTJ> because "if ($glquery)" always returns something. I want to know if it returns
JTJ> NULL.
mysql_query will return FALSE if the query is invalid.
If the query is perfectly valid SQL, but just doesn't return
anything, then you need to use mysql_num_rows() instead - if this is
equal to nothing then nothing was returned.
--
Best regards,
Richard Davey
http://www.phpcommunity.org/wiki/296.html