PDA

View Full Version : supplied argument is not a valid MySQL result resource



BLiZZaRD
03-04-2006, 05:31 PM
I am getting these errors when trying to complete the registration for the game:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/usr/public_html/folder/subfolder/mainmenu.php on line 35

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/usr/public_html/folder/subfolder/mainmenu.php on line 65

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/usr/public_html/folder/subfolder/mainmenu.php on line 109
Invalid Nick/Password


I have searched and prodded and changed everything I can think of and it only gets worse.

Here are the lines:

Line 35:


/* for each older game... */
while($tmpOldGame = mysql_fetch_array($tmpOldGames, MYSQL_ASSOC))
{
/* ... clear the history... */
mysql_query("DELETE FROM history WHERE gameID = ".$tmpOldGame['gameID']);

/* ... and the board... */
mysql_query("DELETE FROM pieces WHERE gameID = ".$tmpOldGame['gameID']);

/* ... and the messages... */
mysql_query("DELETE FROM messages WHERE gameID = ".$tmpOldGame['gameID']);

/* ... and finally the game itself from the database */
mysql_query("DELETE FROM games WHERE gameID = ".$tmpOldGame['gameID']);
}


Line 65:


if (mysql_num_rows($existingUsers) > 0)
{
require 'newuser.php';
die();
}


and line 109: (actually 105 - 109)


case 'Login':
/* check for a player with supplied nick and password */
$tmpQuery = "SELECT * FROM players WHERE nick = '".$_POST['txtNick']."' AND password = '".$_POST['pwdPassword']."'";
$tmpPlayers = mysql_query($tmpQuery);
$tmpPlayer = mysql_fetch_array($tmpPlayers, MYSQL_ASSOC);


Any help as to a fix for these? Thanks a lot!



<EDIT> Okay, you know what, lets pretend for a moment that I am NOT stupid.. cause really I am not, although apparently I can not prove it. When you get the Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource error, it means you are not connecting to the db, right? Well knowing that, I double checked my config.php, and found the dang typo I had in there. Fixed the typo and everything is great! Sorry for being dumb, but I am going to leave this post to show other people how to solve this problem so they don't have to look dumb in public like I seem to be getting used to. *sigh* </EDIT>

Twey
03-04-2006, 06:08 PM
Where is $tmpOldGames defined? Make sure it's returning true.
Sounds like your mysql_connect() and/or mysql_select_db() call(s) is/are failing somewhere.

BLiZZaRD
03-04-2006, 06:55 PM
Thanks Twey, you were probably reading or answering when I edited. The problem was a stupid tiny little typo in my db name in the config.php.

I did fix it though and all works well!

Now if I can get a little help with my other script in this php forum I think I will be all set for a while :)


Thanks again!