I'm tracking a bug in mysql that results in duplicate insert queries. The php script executing the mysql queries runs fine on my dev server (XP IIS5 PHP 4.3.10) with no duplicate inserts. When the script is run on the test server (Win 2K3 IIS6 PHP 4.3.10) the dupe insert bug presents. Both servers use the same mysql server, 5.0.27.
I've exhausted previous causes of this undesired dupe insert behaviour from previous experience:
--HTML/CSS validation errors (all fine)
--Javascript causing headers to send twice (this script has no javascript)
--Mishandled SESSIONs, javascript redirects and meta-refreshes (checked, nothing afoot)
I've monitored headers with FF LiveHeaders and the script is definately not submitting headers twice resulting in the queries executing twice.
I've also debugged by outputting all sql queries generated by this script to a log file with a microtime() stamp. The log shows no duplicate queries sent by the script, yet these duplicate records appear in the tables.
The only lead I have is that 3 out of 4 insert queries result in identical, duplicate records The 4th duplicate is not. The 4th sql nsert query gets two values from php variables storing mysql_insert_id() values from 2 previous insert queries. The original 4th record contains 2 correct mysql_insert_id() values, the duplicate 4th record has default '0' instead.
There doesn't seem to be anything wrong with the code since it runs 100% fine on XP+IIS5. PHP is configured pretty well much the same on both servers.
I've run out of ideas to debug further and any fresh perspectives would be appreciated.
Start Free Trial