iStriide Posted August 7, 2011 Share Posted August 7, 2011 My table in weapons is wiped clean, but this bit of code will not work for some odd reason. <?php $achievements = "SELECT * FROM weapons WHERE Username = '$session'"; $run_achievements = mysql_query($achievements) or trigger_error(mysql_error()); $num_weapons = mysql_num_rows($run_achievements); if($num_weapons >= 1){ }else{ $date = date("m-d-Y"); $find_gamerscore = "SELECT Attack FROM stats WHERE Username = '$session'"; $run_gamerscore = mysql_fetch_array(mysql_query($find_gamerscore)) or trigger_error(mysql_error()); $other_attack = $run_gamerscore['Attack']; $gamerscore = $player_gamerscore + 10; $attack = $other_attack + 15; // Some of the varibales are from other parts of the code, and they do work mysql_query("INSERT INTO achievements SET Username = '$session', Achievement_Name = 'Your first weapon!', Achievement_Image = '$weapon_image', Achievement_Description = 'You earned this achievement by buying your first ever weapon.', Achievement_Score = '10', Achievement_Reward_Name = 'Increased Attack +15', Date = '$date'"); mysql_query("UPDATE stats SET Gamerscore = '$gamerscore', Attack = '$attack' WHERE Username = '$session'") or trigger_error(mysql_error()); echo "$gamerscore && $attack && $date"; } ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 7, 2011 Share Posted August 7, 2011 What do you mean by it "it will not work"? You have to give us some information to go on. Are you getting errors, is it doing something differently than you expect? If so, what is it doing and what is it supposed to do. EDIT: This is probably your problem $run_gamerscore = mysql_fetch_array(mysql_query($find_gamerscore)) or trigger_error(mysql_error()); Runt he query first THEN fetch the results $result = mysql_query($find_gamerscore) or trigger_error(mysql_error()); $run_gamerscore = mysql_fetch_array($result) or trigger_error(mysql_error()); Quote Link to comment Share on other sites More sharing options...
iStriide Posted August 7, 2011 Author Share Posted August 7, 2011 I actually just found the problem. For some reason it had to $num_weapons >= 2. I wasn't getting any errors. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.