Just use:

if (!$result){
code here
}

Jeff

> -----Original Message-----
> From: Andrew [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 10, 2001 1:34 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] test for empty $result??
> 
> 
> 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
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to