Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
mysql skip error
Name: Ken Date: October 8, 2003 at 14:45:43 Pacific 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
Name: Barrett Date: October 17, 2003 at 10:27:39 Pacific
Reply:
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.
Summary: I have just installed mysql 3.23. Anytime i try to get into any of the DB's i keep getting a 1044 error saying "Access denied for user '@localhost' to database 'mysql'" Why can't i get into this? I tr...
Summary: It would be helpful to see mysql's error here, and the final sql query: $result10 = mysql_query($sql) or die("Couldn't execute query.problem: $sql ".mysql_error()); See what that outputs and get back ...