I have never done this before and am having some trouble. Could someone tell me where I am going wrong:

 $sql = mysql_query("UPDATE `gigs` (txnid, payment_amount, payment_status, itemid, createdtime) VALUES (
                '".$data['txn_id']."' ,
                '".$data['payment_amount']."' ,
                '".$data['payment_status']."' ,
                '".$data['item_number']."' ,
                '".date("Y-m-d H:i:s")."' 
                )WHERE (gigname)=".$data['item_number']."'" , $link);

In case I have gone so far wrong you can't see what I am trying to do I want to update the table 'gigs' with the information sent from paypal, and I want to enter it into the row in gigs where the item number is the same as the gigname.

I tested it without the WHERE and it works fine, just goes onto a different line.

Thanks in advance

5 Years
Discussion Span
Last Post by seslie


You are using the syntax for an INSERT statement instead of an UPDATE statement. Update data in mytable1 with data from mytable2 looks like this

UPDATE mytable1, mytable2 
set mytable1.myfield1 = mytable2.myfield1,
mytable1.myfield2 = mytable2.myfield2
where mytable1.item_number = mytable12.gigname

If you are posting from php or some other input then replace the mytable2 references with the variable information and do not fut the table2 entry on the UPDATE line.


Hi gilgil2,

rch1231's right..u're using insert query..the correct syntax is
UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value

SET is the keyword you're missing here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.