Forum Moderators: coopster
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
This only occurs when there is a lot of data being returned. I believe it only happens when there are a lot of rows. I have trimmed down the amount of data for each row, but I still get the message at times.
I have looked at the result resource when it succeeds and when it fails. When it succeeds, the result resource is "#25", or some similar string, such as "#27". When it fails, it is also "#27". So I do not understand what is going on. I had the same error when I tried mysql_num_rows under the same circumstances.
Any suggestions?
Thank you very much,
Mel
It is more than likely your query statement is in error. Try to get the error like so...
$result = mysql_query("SELECT * FROM table") or die (mysql_error());
if your query errors out, that will return the actual error from mysql and display it to the screen and kill the script. It helps when trying to debug queries. More tips can be found in the PHP Troubleshooting tips thread in the PHP Library [webmasterworld.com].
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
The table I am going after has more than 300 fields, of which most are ints, 1-character flags and dates. There are 46 varchar fields and 10 blobs. Does that help?
$link = mysql_connect('server', 'user', 'password')
or exit('Could not connect (' . mysql_errno() . '): ' . mysql_error());
$db = mysql_select_db('database', $link)
or exit('Could not select database (' . mysql_errno() . '): ' . mysql_error());
$sql = "SELECT * FROM table"; // query statement
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) { // Fail here? Query statement may be bad.
while ($row = mysql_fetch_array($result)) {
// process result set
}
} else {
exit('No records returned');
}You said this script only runs the mysql_query() function once, can you confirm that as well?