seany123 Posted November 7, 2009 Share Posted November 7, 2009 Im getting this error: 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 'update = 0 WHERE id = 1' at line 1 now i have narrowed it finally down to this page... <?php //UPDATE PRISON $query = "SELECT * FROM players"; $result = mysql_query($query) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $prison = $row['prison'] - 1; if($prison < 0){ $prison = 0; } $query = sprintf("UPDATE players SET prison = %d WHERE id = %d", $prison, $row['id']); mysql_query($query) or die(mysql_error()); } //UPDATES HOSPITAL $query = "SELECT * FROM players"; $result = mysql_query($query) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $hospital = $row['hospital'] - 1; if($hospital < 0){ $hospital = 0; } $query = sprintf("UPDATE players SET hospital = %d WHERE id = %d", $hospital, $row['id']); mysql_query($query) or die(mysql_error()); } //UPDATES GANG CRIME TIME. $query = "SELECT * FROM gangs"; $result = mysql_query($query) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $crime_time = $row['crime_time'] - 1; if($crime_time < 0){ $crime_time = 0; } $query = sprintf("UPDATE gangs SET crime_time = %d WHERE id = %d", $crime_time, $row['id']); mysql_query($query) or die(mysql_error()); } //UPDATES UPDATE $query = "SELECT * FROM players"; $result = mysql_query($query) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $update = $row['update'] - 1; if($update < 0){ $update = 0; } $query = sprintf("UPDATE players SET update = %d WHERE id = %d", $update, $row['id']); mysql_query($query) or die(mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 7, 2009 Share Posted November 7, 2009 this $query = sprintf("UPDATE players SET update = %d WHERE id = %d", $update, $row['id']); should be $query = sprintf("UPDATE players SET `update` = %d WHERE id = %d", $update, $row['id']); update is a mysql reserved keyword Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 7, 2009 Author Share Posted November 7, 2009 this $query = sprintf("UPDATE players SET update = %d WHERE id = %d", $update, $row['id']); should be $query = sprintf("UPDATE players SET `update` = %d WHERE id = %d", $update, $row['id']); update is a mysql reserved keyword i did that and got this error: Unknown column 'update' in 'field list' Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 7, 2009 Share Posted November 7, 2009 is the field name right seems there is no field such as "update" in your players table 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.