Jump to content

Syntax Error


AzaraelIshanti

Recommended Posts

I have no doubt that I'm missing something obvious, but I'm getting an infrequent syntax error from the simplest of MySQL queries. Background info:

 

Table "profiles" has two columns "id" (int 2) and "joindate" (int 10). Stored as an integer on the table 'cause I have no use for the date there, I manipulate it elsewhere in the program. Anyway, not relevant...

 

Here's the query. $rightnow is getting the time and $id refers to the correct (tested this already...) id of the player trying to update their profile.

 

 

$rightnow = time();

$mysql_query2 = "INSERT INTO profiles (id, joindate) VALUES ($id, $rightnow)";

 

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 ' 1355098639)'

 

Needless to say I'm extremely annoyed, it seems quite straightforward. I have also run into other random errors with the final value of random simple MySQL queries. Happens about once a month and it's completely inexplicable. I end up COPYing and PASTEing another unrelated MySQL call (which to the eye looks identical...) and simply replace the COPYed values with the new values I'm trying to pass...and it works! But...the end result is, as far as I can tell, identical. But copying a working query and replacing values work, writing a new one doesn't...so I'm doing SOMETHING wrong? Or my MySQL server just hates me...

 

HELP! I'm annoyed!

Edited by AzaraelIshanti
Link to comment
Share on other sites

Well, I am fairly an idiot, you are right. I must've printed the ID from a different page for a similar process. One of the previous MySQL calls was failing and not setting up the id correctly, so yea, it didn't get a value, was trying to pass a ' '. But, while we're both here, I was under the impression that int(2) referred to the number of digits? If not, why does it not have 01 as the value on the database? It just seems to say 1...

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.