0

Here is my code which is generating the error:

 $query =" INSERT INTO clients (client_id,name,surname,tel1,tel2,id_num,address,zip_code) VALUES  ($updating_id,$updatedName1,$updatedSurname1,$updatedTel1,$updatedTel2,$updatedAddress1,'0111') 
                 ON DUPLICATE KEY UPDATE (name='$updatedName1',surname='$updatedSurname1',tel1=$updatedTel1,tel2=$updatedTel2,id_num=$updatedId_num1 address=$updatedAddress1,zip_code='0111')";

and here's the error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '455 4885, 011 5558 556,132 heeldon str borrowdale,'0111') ' at line 1

halfer
  • 19,824
  • 17
  • 99
  • 186
  • You are vulnerable to [sql injection attacks](http://bobby-tables.com), and have forgotten to quote most of your values. `tel2=011 5558 556` is **NOT** valid sql. – Marc B Jul 20 '15 at 14:35
  • @Jay Blanchard initially I was trying to update only but that's leading to a duplication, of the record the one updated and the one as it was, – Tichaona Masanga Jul 20 '15 at 14:37
  • @Jay Blanchard so I was advised to used the following code to solve the issue --- INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; – Tichaona Masanga Jul 20 '15 at 14:38

0 Answers0