0

What is wrong with this Query?

INSERT INTO Registration 
  (`Status`, `String`) 
VALUES 
  ('Confirmed', '0') 
WHERE `String` = '". mysql_real_escape_string($user) ."'

1A:

UPDATE Registration 
       `Status` = 'Confirmed', 
       `String` = '0' 
 WHERE `String` = '". mysql_real_escape_string($user) ."'

3 Answers 3

5

You don't specify a WHERE clause on an INSERT query, only UPDATE.

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

1 Comment

Oh, that makes sense! So, I would need to to this [see 1A on original post]?
2

Use:

UPDATE Registration 
   SET `Status` = 'Confirmed', 
       `String` = '0' 
 WHERE `String` = '". mysql_real_escape_string($user) ."'

INSERT is for brand-new records; if you are change values associated to an existing value -- you need to use UPDATE.

Reference:

Comments

1

It might be worth combing over this page: http://dev.mysql.com/doc/refman/5.1/en/insert.html

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.