test for empty $result??
| From: | Andrew | Date: | Mon, 10 Sep 2001 17:34:09 +0000 |
| Subject: | test for empty $result?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66787@lists.php.net to get a copy of this message | ||
I know that this has been discussed before, but I cannot find the threads
so...
I have a function that does a mysql_query and want to break if the SQL query
didn't return any rows in $result.
empty(), isset() will not work, for obvious reasons.
Can anyone suggest an alternative?
$sql="select row from table where field = \"1\"";
$link_id = mysql_connect($hostname, $username, $password);
mysql_select_db($database, $link_id);
$result = mysql_query ($sql, $link_id) or die;
//this doesn't work...right?
if (empty($result)) break;
best,
andrew