Forum lock help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Forum lock help

Post 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
User avatar
robshanks
Forum Commoner
Posts: 32
Joined: Sun Aug 05, 2007 9:27 pm
Location: Hull, UK

Post 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);
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

Isn't "lock" a reserved word?
Try changing it to "locked"
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

:oops: now i feel like a dummy lol lock was a reserved word :S
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You can still use it, just back tick the field name

Code: Select all

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