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
https://forums.phpfreaks.com/topic/244098-mysql_query-update-problem/
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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.