Zac Brown
Zac Brown

Reputation: 6063

SQL Query Error

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) ."'

Upvotes: 0

Views: 143

Answers (3)

OMG Ponies
OMG Ponies

Reputation: 332521

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:

Upvotes: 2

PureForm
PureForm

Reputation: 1003

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

Upvotes: 1

Phil
Phil

Reputation: 164733

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

Upvotes: 5

Related Questions