Eladamri Posted March 31, 2008 Share Posted March 31, 2008 First I have no idea of why is this wrong ... the code looks right to me, I have made UPDATE codes like this and they ahve worked fine so far. Anyway, enough blabla, here is the stuff: <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $rowID = 1; $time = 24; $query = "UPDATE player SET time='$time' WHERE id='$rowID'"; $result = mysql_query($query); if ($result) echo "<p>The developer has been successfully updated.</p>"; else echo "<p>There was a problem updating the developer.</p>",mysql_error(),"<br />"; ?> Yes this is the whole code on the page. And when I go to that page I have: There was a problem updating the developer. 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 ''player' SET time='24' WHERE id='1'' at line 1 The 'time' field is INT(3). ID 1 exists. The table is in fact called "player" (and yes, I did try with and without singlo-quotes). The result is the same. I simply don't get it. Any help would be great, it's kind of the central bone of my site (well in theory it should update every time fiel to 24, not only ID 1, but right now I'm just trying with ID 1 to make it simpler to find the mistake) And ... MySQL client version: 4.0.24 Used PHP extensions: mysql Quote Link to comment https://forums.phpfreaks.com/topic/98740-update-error/ Share on other sites More sharing options...
cooldude832 Posted March 31, 2008 Share Posted March 31, 2008 time is most likely a resereved word so you need to quote it <?php $q = "update `player` set `time` = '".$time."' where id = '".$rowID."'"; Quote Link to comment https://forums.phpfreaks.com/topic/98740-update-error/#findComment-505275 Share on other sites More sharing options...
pocobueno1388 Posted March 31, 2008 Share Posted March 31, 2008 time is most likely a resereved word so you need to quote it No, "time" is not a reserved word. Have you tried printing out the query? Change echo "<p>There was a problem updating the developer.</p>",mysql_error(),"<br />"; To echo "<p>There was a problem updating the developer.</p>",mysql_error(),"<br />$query"; Quote Link to comment https://forums.phpfreaks.com/topic/98740-update-error/#findComment-505277 Share on other sites More sharing options...
Eladamri Posted March 31, 2008 Author Share Posted March 31, 2008 Thanks a bunch cooldude. It does work now I'm amazed by how fast your answers were. Pocobueno: since it's now fixed, I don't need it but I will keep it in mind, it looks like an usefull tip Quote Link to comment https://forums.phpfreaks.com/topic/98740-update-error/#findComment-505280 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.