Re: Supplied argument is not a valid MySQL result resource

From: Date: Sun, 28 Apr 2002 22:49:25 +0000
Subject: Re: Supplied argument is not a valid MySQL result resource
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95038@lists.php.net to get a copy of this message
I am betting the problem is simply your semicolon... never use a semicolon in a php mysql query. It doesn't need one. In general, though, you should write your query such that it will tell you exactly what went wrong... Re-write this like so: $sql = 'select * from aannh_towns'; $result = mysql_query($sql) or exit("Query failed. Error: ".mysql_error()."<BR>".$sql); This will spit out the mysql error as well as the query as mysql tried to execute it. You could even make this a function if you like... then all you'd have to do is pass the query into it and it'll spit out the result resource. Something like: function sql_query($sql) { $result = mysql_query($sql) or exit("Query failed. Error: ".mysql_error()."<BR>".$sql); return $result; } This will save you a lot of time searching for what broke! :-) Cheers, # Nathan ----- Original Message ----- From: "Dan McCullough" <McWC@rocketmail.com> To: <php-general@lists.php.net> Sent: Sunday, April 28, 2002 4:14 PM Subject: [PHP] Supplied argument is not a valid MySQL result resource What does that error mean? $result = mysql_query('select * from aannh_towns;'); echo 'info stored'; while ($query_data = mysql_fetch_array($result)) { echo "", $query_data['town'], "", $query_data['town_id'], ""; } ?> ===== dan mccullough -------------------------------------------------------- "Theres no such thing as a problem unless the servers are on fire!" __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#95038) next »