PDA

View Full Version : How do I fix this


Zecherieh
Wed 14th Feb '01, 9:25pm
I get this error on my userfield table

Warning: Supplied argument is not a valid MySQL result resource in /usr/local/apache/htdocs/phpMyAdmin/lib.inc.php on line 507



That is when looking at it in phpMyAdmin

What the heck is the fix?

Zecherieh
Wed 14th Feb '01, 9:33pm
Well what ever used to be there is gone now - I remembered when I did my upgrade that that table was empty and the board worked so I just killed the table and rebuilt it

Board back up - that is all that matters to me ;)

I assume that is the table where location and such is stored?

Zecherieh
Wed 14th Feb '01, 9:55pm
If someone knows how to fix an error like that I still would be interested in knowing how to, in case it happens again.

MattR
Thu 15th Feb '01, 10:02am
That occurs when a query identifier is passed to a mysql_* function that doesn't exist.

So, the first thing to check is what is the function at that line? It's probably a mysql_fetch_* function.

Then look above it and see what it's doing -- if it is a PHP code error it would be something like this:
[quote]
$users = $DB_site->query( "SELECT *
FROM user
WHRE username != "Bob"
AND otherthings" );

while( $user = $DB_site->fetch_array( $userrs ) ) {
.....
[/code]

The error in this case is that the variable is misspelled. The only times I see this on my server is if PHP breaks connection to the DB server in the middle of executing a query -- so the code is OK but because it dies the initial query works, but the fetch_array function will die because $users is no longer a valid result.

The only way around that would be to put a check before it -- maybe something like:

$users = "blah";

if( $users == "" ) {

die "Lost connection to DB server";
// or even you can re-instantiate the DB connection
// and then re-run the query.
}



Or there are a couple other ways I'm sure that you could write in some error checking / reconnecting and such. I wrote a basic DB reconnect in the query function to reconnect if it somehow drops -- but it'd be hard to do in the fetch_array function unless you pass the actual query on.

Another thing.. I wonder how hard it would be to work into vB a "smart" error checking into the db class that parses the error and if it detects something like that executes the appropriate steps to resolve it?