Computing.Net > Forums > Programming > mysql skip error

mysql skip error

Reply to Message Icon

Original Message
Name: Ken
Date: October 8, 2003 at 14:45:43 Pacific
Subject: mysql skip error
OS: xp
CPU/Ram: 2.4
Comment:

Can anyone please tell me what mysql returns if no records are found?
Here is what I am doing:
$query = "select from ....";
$result = mysql_query($query);
if (!$result) :
print "Could not find data!";
endif;
if($result){ blah blah...}

It seems to skip my error message. Any ideas?
Thanks in advance,
Ken


Report Offensive Message For Removal


Response Number 1
Name: Barrett
Date: October 17, 2003 at 10:27:39 Pacific
Reply: (edit)

Looks like you're coding in PHP, right? Admittedly I'm a PHP newbie myself but...

According to the users manual (http://us2.php.net/manual/en/function.mysql-query.php), mysql_query only returns False if the query fails. So if your query is runnable, $result will have a return value even if there are no results.

Instead of if(!$result), try using if(!mysql_fetch_row($result)) That should evaluate to true if there are no result rows.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: mysql skip error

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes Today.
Discuss in The Lounge