Jump to content

Recommended Posts

Hi all,

 

Whats the correct way of putting this statement?

$query ="UPDATE customers SET
(title, forename, surname, company, nameno, fline, sline, city, state, zip, country, tax, email, phone, fax, username, password, newsletter)
VALUES
('$title', '$forename', '$surname', '$company', '$nameno', '$fline', '$sline', '$city', '$state', '$zip', '$country', '$tax', '$email', '$phone', '$fax', '$username', '$password', '$newsletter')

WHERE id = '$id';"

 

Link to comment
https://forums.phpfreaks.com/topic/194511-update-help-whats-the-correct-way/
Share on other sites

Sorry,

 

yes this does not work, I am getting

Error: 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 '(title, forename, surname, company, nameno, fline, sline, city, state, zip, coun' at line 2

 

I'm thinking it is likely you are using a mysql reserved keyword in one of you column names. Check the mysql manual to be sure. If you are, just change them and try again.

 

This is one THE most annoying errors. Had it a once and spent days trying to resolve it because of that absolutely useless error feedback.

 

Here's a link:

 

http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

 

--- and this is my lack of knowledge coming out - but can you even use an update query in that format?

 

My understanding was it had to be structured like this:

 

$result = mysql_query("UPDATE example SET age='22',field2='val2',field3='val3' WHERE age='21'")

 

That's not the syntax for an UPDATE query -

UPDATE [LOW_PRIORITY] [iGNORE] table_reference

    SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...

    [WHERE where_condition]

    [ORDER BY ...]

    [LIMIT row_count]

 

 

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.