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()); } ?> Link to comment https://forums.phpfreaks.com/topic/180633-help-after-i-have-set-up-xampp/ 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 Link to comment https://forums.phpfreaks.com/topic/180633-help-after-i-have-set-up-xampp/#findComment-952968 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' Link to comment https://forums.phpfreaks.com/topic/180633-help-after-i-have-set-up-xampp/#findComment-952970 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 Link to comment https://forums.phpfreaks.com/topic/180633-help-after-i-have-set-up-xampp/#findComment-952971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.