Bug #13687 Insert query executing twice
Submitted: 2 Oct 2005 7:34 Modified: 2 Nov 2005 8:10
Reporter: Sivan Narayana Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:3.23.54 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[2 Oct 2005 7:34] Sivan Narayana
Description:
Hello All,
I'm trying to execute a insert query in my PHP script. This will happen in POST method after submitting data. After few cross checkings script will saves the information in database table.And the database type default type. When ever i'm clicking submit button this insert query executing twice. Ths syntax of the insert query is as follows...

$insertQuery = "INSERT INTO serveractivations (associateid,databaseusername,associatename,doj,doa,dop,associatepaidamount,miles,orderid,mop,ddnumber,dddate,bankname,remarks,sessionagentid,excessamount,regionaloffice,invoicenumber,creditamount,payment,nomineename,nomineesex,nomineerelation,nomineeaddress,nomineecity,nomineedob,activationtype,activatedtime) VALUES ('$associateId','$databaseUserName','$associateName','$doj','$doa','$dop','$associatePaidAmount','$miles','$orderid','$mop','$ddNumber','$ddDate','$bankName','$remarks','$sessionAgentId','$excessAmount','$regionalOffice','$invoiceNumber','$creditAmount','$payment','$nomineeName','$nomineeSex','$nomineeRelation','$nomineeAddress','$nomineeCity','$nomineeDob','1',now())";
$insertResult = mysql_query ($insertQuery) or die ("Insert Query Error<BR>$insertQuery<BR>Error:".mysql_error());

In the table definition first i didn't mentioned any unique key. So, it was inserting 2 entries. After i made associateid as unique. Then after it is giving duplicate key error. Please help me in this regard. 

How to repeat:
Hello All,
I'm trying to execute a insert query in my PHP script. This will happen in POST method after submitting data. After few cross checkings script will saves the information in database table.And the database type default type. When ever i'm clicking submit button this insert query executing twice. Ths syntax of the insert query is as follows...

$insertQuery = "INSERT INTO serveractivations (associateid,databaseusername,associatename,doj,doa,dop,associatepaidamount,miles,orderid,mop,ddnumber,dddate,bankname,remarks,sessionagentid,excessamount,regionaloffice,invoicenumber,creditamount,payment,nomineename,nomineesex,nomineerelation,nomineeaddress,nomineecity,nomineedob,activationtype,activatedtime) VALUES ('$associateId','$databaseUserName','$associateName','$doj','$doa','$dop','$associatePaidAmount','$miles','$orderid','$mop','$ddNumber','$ddDate','$bankName','$remarks','$sessionAgentId','$excessAmount','$regionalOffice','$invoiceNumber','$creditAmount','$payment','$nomineeName','$nomineeSex','$nomineeRelation','$nomineeAddress','$nomineeCity','$nomineeDob','1',now())";
$insertResult = mysql_query ($insertQuery) or die ("Insert Query Error<BR>$insertQuery<BR>Error:".mysql_error());

In the table definition first i didn't mentioned any unique key. So, it was inserting 2 entries. After i made associateid as unique. Then after it is giving duplicate key error. Please help me in this regard.
[2 Oct 2005 8:10] Valeriy Kravchuk
Thank you for the proble report. 

You had not provided enough information for us to be able to repeat your problem. Please, send the definition of your serveractivations table. You can get it using "SHOW CREATE TABLE serveractivations" statement.

In the meantime, please, check your PHP code - I believe, you have some logical mistake in it that leeds to sending 2 inserts to the MySQL server.
[3 Nov 2005 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".