Hi I can't work out why this is not working. It works in a separate table or if I don't do Update Where, just Insert into, so that it works on a new row but does will not update the row I want. Any help would be very appreicated. function updatePayments($data){ global $link; if(is_array($data)){ $sql = mysql_query("UPDATE `gigs` SET (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); return mysql_insert_id($link); } } PHP:
You are using wrong syntax. Here's an example of correct updating syntax. UPDATE tablename SET something='something' WHERE something = 'something' Code (markup):
Thanks for your help Arttu, I have changed that but it still doesn't working. I now have this: function updatePayments($data){ global $link; if(is_array($data)){ $sql = mysql_query("UPDATE `gigs` SET txnid = '".$data['txn_id']."' , payment_amount = '".$data['payment_amount']."' , payment_status = '".$data['payment_status']."' , itemid = '".$data['item_number']."' , createdtimed = '".date("Y-m-d H:i:s")."' WHERE gigname='".$data['item_number']."' ", $link); return mysql_insert_id($link); } } ?> Code (markup): Is there anything else I am doing wrong?
error is at the and of the query $sql = mysql_query("UPDATE `gigs` SET txnid = '".$data['txn_id']."' ,payment_amount = '".$data['payment_amount']."' ,payment_status = '".$data['payment_status']."' ,itemid = '".$data['item_number']."' ,createdtimed = '".date("Y-m-d H:i:s")."' WHERE gigname='".$data['item_number']."' ", $link);
Thanks, which bit do I need to change at the end? Arttu, thank you, I tried that though and it still is not working... I am completely lost!
That's not an error, that just tells PHP to use a specific connection. I tested the query and it works, which means that the error occurs because of something that those variables contains. Also, I just realized that those were backtacks around the table name not single quotes, you can put them back if you want(that's not what causes it to not work).
i asking You ONe Question What is Coding and why are you use in language html,Php,xhtml and etc .So please all developer answer this Question .
a MySQL link identifier eg. $link1 = mysql_connect('server', 'mysql_user', 'mysql_password'); $link2 = mysql_connect('server2', 'mysql_user', 'mysql_password'); mysql_query('SELECT * WHERE 1=1', $link1); PHP: link1 will be used.
I think you wrong at mysql syntax . let use basic syntax UPDATE tablename SET field1='value1',field2='value2',....,fieldn='valuen' WHERE field= 'condition' Other .+ your field name should not duplicate with MYSQL constant and MYSQL keyword .such as : name, keyword ,desc + your string which you update must not contains sql injection . such as : ' , / , . Let's check. Goodluck