Sinikka Posted November 10, 2007 Share Posted November 10, 2007 I'm having a problem getting the value to update for the total amount of avatars a person has when they unlock a new one. I've been sitting here looking at the code for the last hour and for the life of me I can't figure out what I'm doing wrong. if ($members[username] == pinknailpolish){ $sql = mysql_query("SELECT * FROM avatar WHERE user_name = '$userid' AND avatar_name = 'Cactus Addict'"); $result = mysql_num_rows($sql); if($result=="0") { $sql = mysql_query("INSERT INTO avatar (user_name, avatar_name, avatar_id) VALUES ('$userid','Cactus Addict','5')"); mysql_query("UPDATE members2 SET avie_count=$members[avie_count]+1 WHERE username = '$userid' AND game = '$game'"); if(!$sql) { echo "Error performing query: ".mysql_error(); } else { $avie0= "<center><br><table width=300 border=1 cellpadding=4 cellspacing=0 bordercolor=#000000 bgcolor=#ffffff><tr><td><img src=images/user_images/opg_1/avies/cactusaddict.gif width=70 height=70 hspace=10 align=left><font color=#000000 size=3 face=verdana><b>Congratulations $username</b></font><font size=2 face=verdana><br><br>You can now use Cactus Addict as an avatar on the forums! </font></td></tr></table></center>"; } } } Link to comment https://forums.phpfreaks.com/topic/76743-can-insert-but-not-update/ Share on other sites More sharing options...
Barand Posted November 10, 2007 Share Posted November 10, 2007 you could just mysql_query("UPDATE members2 SET avie_count=avie_count+1 WHERE username = '$userid' AND game = '$game'"); Link to comment https://forums.phpfreaks.com/topic/76743-can-insert-but-not-update/#findComment-388544 Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 if($result=="0") { shouldn't have the zero in quotes its parsed as the string character 0 not the number zero if($result==0) { Link to comment https://forums.phpfreaks.com/topic/76743-can-insert-but-not-update/#findComment-388545 Share on other sites More sharing options...
Sinikka Posted November 10, 2007 Author Share Posted November 10, 2007 Hmm, I tried both suggestions but it's still not updating the count at all. Link to comment https://forums.phpfreaks.com/topic/76743-can-insert-but-not-update/#findComment-388547 Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 where is $game coming from ? Link to comment https://forums.phpfreaks.com/topic/76743-can-insert-but-not-update/#findComment-388549 Share on other sites More sharing options...
Sinikka Posted November 10, 2007 Author Share Posted November 10, 2007 It's how it defines which game it goes to ie: /user_profile.php?game=1 Link to comment https://forums.phpfreaks.com/topic/76743-can-insert-but-not-update/#findComment-388550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.