Hi Everyone,

Basically i have a reward system on my website as Achievements. On the acievements page i want to display the achievment images that are unlocked and the locked image if the user has not unlocked them. The following code works but still brings back the following error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/*******/public_html/*******/achievements.php on line 32

And here is the code i am using:

			$selectachievement = mysql_query("SELECT * FROM achievementlist");
			while($displayachievement = mysql_fetch_array($selectachievement)) {
			$achievement = $displayachievement['achievementName'];
			$checkunlocked = mysql_query("SELECT * FROM achievements WHERE achievementName ='$achievement' AND achievementUser =            '$currentuser'");
			$achievementunlocked = mysql_num_rows($checkunlocked);
				<td class="achievement" width="120" achievementname="
				<?php echo $displayachievement['achievementName']; ?>">
                <img src="<?php if ($achievementunlocked == "1") { 
				echo $displayachievement['achievementImage']; }
				else { 
				echo "http://clancorner.net/images/achievements/locked.png"; } ?>"></td>

Thanks in advance people!

8 Years
Discussion Span
Last Post by diafol

This error usually means that your SQL statement is wrong.

"SELECT * FROM achievements WHERE achievementName ='$achievement' AND achievementUser =            '$currentuser'"

Paste this (substitute the $currentuser and $achievement vars for existing values) into the SQL window of your MySQL GUI (e.g. phpmyadmin) and run it. See what it says.

OR echo the statement:

echo "SELECT * FROM achievements WHERE achievementName ='$achievement' AND achievementUser = '$currentuser'";

and paste this to the SQL window.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.