...

View Full Version : MySQL syntax error???



lpeek
05-15-2008, 10:24 AM
Hey Hey,

having quite a bit of trouble with some code.

Its all set up correctly, and should work, but i keep getting a syntax error.

heres the code in question:



if ($cmd=="commentpost")
{

$SCREEN_ID = $sid;
$MY_ID = $_SESSION['user_id'];
$BODY = $_POST['comment'];
$cur_date = time();

$BODY = addslashes(nl2br($BODY));

$sql = mysql_query("INSERT INTO `screenshot_comments` (screen_id, user_id, timestamp, body, read) VALUES ('$SCREEN_ID','$MY_ID','$cur_date','$BODY','0')") or die(mysql_error());

$comment_posted = true;
}


the error i get is:

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 'read) VALUES ('57','3','1210842919',abcde' at line 1

ive checked and double checked my database and all the columns are named correctly etc.

Any ideas?

abduraooft
05-15-2008, 10:28 AM
READ is mysql reserved keword, I think ,see http://dev.mysql.com/doc/refman/5.1/en/handler.html

So changing it like `read` may solve the issue. But usage of mysql keywords for naming tables/fields is not a good practice.

lpeek
05-15-2008, 10:33 AM
READ is mysql reserved keword, I think ,see http://dev.mysql.com/doc/refman/5.1/en/handler.html

So changing it like `read` may solve the issue. But usage of mysql keywords for naming tables/fields is not a good practice.

Ah ok then, ill change it and try again.

Confused me a bit because i already have 3 other tables with 'read' as one of the collumn and that gave me no errors.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum