iStriide Posted August 7, 2011 Share Posted August 7, 2011 I have already checked my variables and echoed them and the all work, but my query is not working, so here it is: 2nd query works, but not 1st. <?php $new_player_credits = $player_Credits - $weapon_cost; $new_attack = $weapon_attack + $player_attack; $new_defense = $weapon_defense + $player_defense; $new_strength = $weapon_strength + $player_strength; $new_speed = $weapon_speed + $player_speed; $new_accuracy = $weapon_accuracy + $player_accuracy; $new_range = $weapon_range + $player_range; $new_HBS = $new_attack + $new_defense + $new_strength + $new_speed + $new_accuracy + $new_range * .3; $weapon_upgrade = $weapon_cost * 1.3; $weapon_sell = $weapon_upgrade * .40; mysql_query("UPDATE stats SET HBS = '$new_HBS', Current_Credits = '$new_player_credits', Attack = '$new_attack', Defense = '$new_defense', Strength = '$new_strength', Speed = '$new_speed', Accuracy = '$new_accuracy', Range = '$new_range' WHERE Username = '$session'"); mysql_query("INSERT INTO weapons SET Username = '$session', Weapon_Name = '$weapon_name', Weapon_Image = '$weapon_image', Weapon_Shop_Level = '$weapon_level', Weapon_Level = '$weapon_level', Weapon_Current_Value = '$weapon_upgrade', Weapon_Sell_Value = '$weapon_sell', Weapon_Attack = '$new_attack', Weapon_Defense = '$new_defense', Weapon_Strength = '$new_strength', Weapon_Speed = '$new_speed', Weapon_Accuracy = '$new_accuracy', Weapon_Range = '$new_range'"); header("Location: http://www.halobattles.comyr.com/profile.php?player=$session"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/244098-mysql_query-update-problem/ Share on other sites More sharing options...
trq Posted August 7, 2011 Share Posted August 7, 2011 Have you done any debugging at all? Your not even checking to see if mysql_query fails or not. Quote Link to comment https://forums.phpfreaks.com/topic/244098-mysql_query-update-problem/#findComment-1253609 Share on other sites More sharing options...
iStriide Posted August 7, 2011 Author Share Posted August 7, 2011 It shows this error: Notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Range = '20' WHERE Username = 'Tyler'' at line 1 in /home/a5719220/public_html/purchase_link.php on line 65 Quote Link to comment https://forums.phpfreaks.com/topic/244098-mysql_query-update-problem/#findComment-1253610 Share on other sites More sharing options...
trq Posted August 7, 2011 Share Posted August 7, 2011 You really should check your queries succeed of fail (in your code) before proceeding. Anyway, range is a reserved word in mysql. You should change the name of the field to something that isn't reserved, or you can (not recommended) souround the reserved word in `backticks`. Quote Link to comment https://forums.phpfreaks.com/topic/244098-mysql_query-update-problem/#findComment-1253611 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.