Hi

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

Hello

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.