Jump to content

What is wrong with this UPDATE !

Recommended Posts

Hello,I'm not sure if this should be here or on the PHP forum. sorry.-----I have been stuck with this for 2 hours now and have read lots google results without any success.The following query gives me an error :"UPDATE marker SET type='$type', for='$for' WHERE id = '$id'"also tried :"UPDATE `marker` SET `type`='$type',`for`='$for' WHERE `id`='$id'"also :"UPDATE marker SET type='$type', SET for='$for' WHERE id = '$id'"also :"UPDATE marker SET type='$type' AND SET for='$for' WHERE id = '$id'"also :"UPDATE marker SET type='$type' AND for='$for' WHERE id = '$id'"i tried many others also.The error is something like :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 'SET for='Sale' WHERE id = '1'' at line 1IT ONLY WORKS FOR A SINGLE FILED QUERY LIKE :"UPDATE marker SET type='$type' WHERE id = '$id'"How can i get this thing work ?!Thanks,

Edited by Mesh3L
Link to post
Share on other sites

Since "FOR" is a reserved word in MySQL, you need to surround the name with backquotes. So, this is the correct version:"UPDATE `marker` SET `type`='$type',`for`='$for' WHERE `id`='$id'"If that doesn't work, print out the query you generate to check for errors.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...