Jump to content

UPDATE error ....


Eladamri

Recommended Posts

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

Link to comment
Share on other sites

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

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.