[SOLVED] Â On Duplicate Update |
12/18/2014 7:44:20 AM |
PHPRunner General questions | |
![]() Hi All |
|
![]() |
romaldus 12/18/2014 |
Hi All been a long time since i posted <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=76470&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' /> merry christmas to all and your families <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=76470&image=2&table=forumreplies' class='bbc_emoticon' alt=':D' /> Can anyone help me with a project i am trying to do i have a database where customers can purchase support blocks i have 7 tables when a customer places a purchase order for say 5 credits it writes the transaction to the purchase table, i also have a kredits table where a balance of credits is kept if a customer purchased credits previously i want the total of credits increased for that customer so if they already had 2 want the table to update the total to 7 if they had not purchased before then i just want it to create the record. i have this code in the purchase add page after record added but my SQL code does not work, i cannot work out where i have gone wrong but i think it is to do with adding the blocks, can anyone tell me where i have gone wrong. global $conn; $strSQLSave = "INSERT INTO kredits SET customer_id = '".$values["customer_id"]."',blocks = '".$values["blocks"]."',cost = '".$values["cost"]."',account_no = '".$values["account_no"]."',ON DUPLICATE KEY UPDATE blocks =blocks+ '".$values["blocks"]."'";db_exec($strSQLSave,$conn); thank you Kev
|
![]() |
Graphix author 12/18/2014 |
|
![]() |
Sergey Kornilov admin 12/18/2014 |
Add single quotes around account number: global $conn; |
![]() |
Graphix author 12/18/2014 |
Add single quotes around account number: global $conn;
|
![]() |
Sergey Kornilov admin 12/18/2014 |
I know what you have tried and why it errors. Use the code I have supplied. |
![]() |
Graphix author 12/18/2014 |
I know what you have tried and why it errors. Use the code I have supplied.
|