Code works but still shows a num_rows error?
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 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> <?php } Thanks in advance people!
1 Answer
just use @ to hide the errors:
<?php $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> <?php } ?> Posted: is_set 2 of 2 people found this answer helpful. Did you? Yes No Thanks my friend, but do you know why i am getting the error? make sure that the mysql query is valid try to write it in your phpmyadmin |
© Advanced Web Core. All rights reserved