Jump to content

mysql_query UPDATE problem.


iStriide

Recommended Posts

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");

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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`.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.