0

im trying to update my table using the following query...

 $query = mysql_query("UPDATE `outgoings` (id, user_id, bill, bill_name, bill_description, bill_colour ) VALUES ('$id', '$uid', '$bill', '$billname', '$billdescription', '$billcolour') WHERE id = '$id'") or die(mysql_error());

It returns...

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 '(id, user_id, bill, bill_name, bill_description, bill_colour ) VALUES ('', '8464' at line 1

Ive tried removing ' around my variables and googling for alternative methods but cant seem to figutre out what imdoing wrong?

0

4 Answers 4

4

Use this syntax for update statements:

UPDATE `outgoings` set id = '$id', user_id = '$uid' ... where ...

You got it mixed with insert statement I guess.

Sign up to request clarification or add additional context in comments.

1 Comment

This is correct. The syntax the OP used is for INSERT and doesn't work for UPDATE.
0

It looks like your ID is empty (...VALUES ('',...). Should there be an ID there?

Comments

0

Your $id seems to be empty or not defined yet. Read mysql.error() up to the end.

Comments

0

The update query has different syntax, something like that:

UPDATE `outgoings` SET user_id='$uid', bill='$bill' WHERE id = '$id'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.