On Tue, 27 May 2003, Todd Barr wrote: > Morning > > We recently moved out site to a new server, and scripts that use to work, no longer > do. > > Like mysql_fetch_array worked fine, but now I am getting this error > > mysql_fetch_array(): supplied argument is not a valid MySQL result resource > > Any ideas?
mysql_error() is your best friend, utilize this friendship. See http://www.php.net/mysql-fetch-assoc for example uses. Basically, mysql_query() returns false on failure instead of a mysql resource, I am guessing you are trying to use this value of false like a resource ... don't do that :) $sql = "SELECT foo,bar FROM bleh"; $result = mysql_query($sql); $result will be a result OR false, let's check for that using a simple example: if (!$result) { print "Could not run query ($sql): " . mysql_error(); exit; } This way we don't use a bogus $result later in the code, like with one of the fetch functions. May as well check the number of returned rows too: if (mysql_num_rows($result) < 1) { print "No rows to fetch, silly."; exit; } We're about ready to fetch some data from $result now :) Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php