Page 1 of 1

Forum lock help

Posted: Tue Aug 07, 2007 12:29 pm
by Smackie
I do not know whats going on i mean i been on this script for the whole day yesturday.. I believe its somewhere in the insert part :S but here is the part of the script i believe its in

Code: Select all

$sql="INSERT INTO forum_question(forumid, topic, detail, userid, lock, datetime)VALUES('$forumid', '$topic', '$detail', '$userid', '$lock', now())";
$result=mysql_query($sql);
I just get ERROR on that but when i take out lock, and '$lock', it works fine lock is in the database between userid and datetime and i have at the top $lock = $_POST['lock']; but if i put
or die(mysql_error());
i get

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 'lock, datetime)VALUES('1', 'test', 'test', '14', '1', now())' at line 1
can someone tell me whats wrong here :S

Thank you
Smackie

Posted: Tue Aug 07, 2007 12:43 pm
by robshanks
If lock as an integer type try not single quoteing it in the values section:

Code: Select all

$sql="INSERT INTO forum_question(forumid, topic, detail, userid, lock, datetime)VALUES('$forumid', '$topic', '$detail', '$userid', $lock, now())";
$result=mysql_query($sql);

Posted: Tue Aug 07, 2007 12:45 pm
by thiscatis
Isn't "lock" a reserved word?
Try changing it to "locked"

Posted: Tue Aug 07, 2007 12:55 pm
by Smackie
:oops: now i feel like a dummy lol lock was a reserved word :S

Posted: Tue Aug 07, 2007 7:08 pm
by RobertGonzalez
You can still use it, just back tick the field name

Code: Select all

INSERT INTO `table` (`fieldname`) VALUES ('value');