Insert Statement store double duplicate data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pcb
Forum Newbie
Posts: 4
Joined: Thu May 10, 2007 6:38 am

Insert Statement store double duplicate data

Post by pcb »

Hai all, my head spinning away with this duplicate data, it is not because of the database, but i think because of my codes, i say that because i try enter data manually using phpmyadmin, single data will be inserted, but when i running through my application, there will be double data inserted which is the first data is the correct data while the second one contain no value but have the primary key only because i set the AUTO_INCREMENT, i already check maybe there will be a double command to execute the insert statement, but cannot find one. here i post my insert statement:

Code: Select all

$query = "insert into personal(program, nama, jantina, ic_lama, ic_baru, warganegara, keturunan, tarikh_lahir, negeri_kelahiran, alamat_tetap, alamat_pejabat, no_tel_rumah, no_tel_pejabat, no_tel_bimbit, no_faks_rumah, no_faks_pejabat, alamat_surat, approve) values ('$program','$nama','$jantina','$ic','$ic2','$warganegara','$keturunan','$hari $bulan $tahun','$select_negeri','$alamat_tetap','$alamat_pejabat','$no_rumah','$no_pejabat','$no_tel_bimbit','$no_fak_rumah','$no_fak_pejabat','$alamat_surat','$terms')";
mysql_query($query) or die('Error, insert query failed');
 
$query = "FLUSH PRIVILEGES";
And Here, the data in the phpmyadmin with the null value:

Image

Thanks a bunch
SBro
Forum Commoner
Posts: 98
Joined: Tue Sep 30, 2003 10:06 pm

Re: Insert Statement store double duplicate data

Post by SBro »

Can you post any of the code around your query? I'd guess that the query is being executed from within a loop of some form.
Post Reply