-2

i dont know where i went wrong. I thought i've already use the right syntax. but still there's error on my queries

"INSERT INTO tempahan(id,nama,tarikh,mula,akhir,unit,bil,sebab) VALUES ('$id','$nama','$tarikh','$mula','$akhir','$unit','$bil,'$sebab')
ON DUPLICATE KEY 
UPDATE
tarikh ='$tarikh'
,mula='$mula'
,akhir='$akhir'
,unit='$unit'
,bil='$bil'
,sebab='$sebab'
";

and it will show 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 '','') ON DUPLICATE KEY UPDATE tarikh='' , mula' at line 1

1 Answers1

0

The INSERT statement is given so that older fields cannot be inserted to new value. If your older values are the same as your new ones.

You may design the table with PRIMARY / UNIQUE key, it won't allow INSERTS a duplicate one.

On Duplicate Key Update same as insert

Community
  • 1
  • 1
Ramalingam Perumal
  • 1,367
  • 2
  • 17
  • 46