RE: Insert queries add TWO records to database
Thanks for the note, I will determine if this applies to our situation. However I believe I found the solution to my problems to be apache related. I found that after upgrading to apache 1.3.20, MANY of our web server requests were duplicated & some times tripled when using IE 5.5 (and presumably others, but not telnetting straight to port 80). This meant that the page would be loaded twice per actual request. This was a problem evident in the apache access_log (2 page executions per "refresh") whether or not I hit the database (so possibly related to php but not to database (sybase) connectivity/functionality). I did not test this with non-php pages. This problem immediately went away when going back to apache 1.3.9 which is where we were at before upgrading to php4. Apache support states it is not a bug with apache, but with IE & hasn't done anything about it. As for the mention below, I don't see the original code you're referencing, but I don't see why that would run twice. The first statement places the return value of the mysql_query command into the variable $res_insert_campaign -- NOT the entire "executable command" of mysql_query($sql,$conn). If later one evaluates that variable (if !$res_insert_campaign), there is no possibility it would re-run that command, since $res_insert_campaign, is a SCALAR VARIABLE, not something which knows anything about your mysql_query call. I think the double-row insertion problems people are experiencing are due to the double-running of each php command due to this odd apache issue. Thanks, Rob. -Original Message- From: Sebastiaan J.A. Kamp [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 04, 2001 6:21 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Insert queries add TWO records to database It's more of a PHP than a MySQL 'problem' & certainly not a MySQL bug, but... Upon processing "$res_insert_campaign=mysql_query($sql,$conn);" the script will insert a line into your database. Then, upon evaluating "if (!$res_insert_campaign) {" it will do "if (!mysql_query($sql,$conn))" and insert another line... Try being less 'indirect' about what you want: $sql = "INSERT INTO Campaign (CampaignName,CampaignDesc,StartDate,EndDate,CompanyId,CampaignStatus,Admini stratorId) VALUES ('$name','$desc','$start_date','$end_date',$company_id,0,1)"; if (!mysql_query($sql,$conn);) { return false; } Regards, Sebastiaan J.A. Kamp Operating system: WinNT4 PHP version: 4.0.6 PHP Bug Type: MySQL related Bug description: Insert queries add TWO records to database All my insert queries seem to add two records to the database instead of one. I was using MS Access 2000 and did not have the problem. I am now using MySQL and all insert queries add 2 recs?! [...CUT...] A guy in the US seems to be having the same problem with Sybase. His details are: Rob Donat Sedonatech, Inc. 1735 W. Diversey Suite 521 Chicago, IL 60614 [EMAIL PROTECTED] 312-501-1200 cell 773-388-0271(2) office(fax)
RE: Insert queries add TWO records to database
Check your access_log (or IIS equivalent -- if this is occurring on IIS then it's got to be a php bug). I wasn't convinced that it was strictly a browser issue (IE) when apache support laid blame there. However the problem DOES go away by using an older version of apache, AND was not reproducable by telnetting into port 80. Maybe it's a browser/php interaction issue. Try this: telnet www.myserver.com 80 GET /whatevermyproblempageis.phtml See in the log if it gets run twice Check to see if the insert/update is run twice The problem is not with mysql, since I have the exact issue within Sybase & I've seen people have it with postgres. Perhaps PHP is somehow internally redirecting the request so it runs twice. My initial suspicion was it was a PHP bug, but like I say, it only occurs with Apache 1.3.20, not on older 1.3.9. Rob. -Original Message- From: John (*\*) [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 5:53 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Insert queries add TWO records to database I'm not convinced as I have the same problem in Netscape. More likely to be a PHP or MySQL configuration problem as the code is fine. Or maybe IIS? May try it on a different server. Regards, John Stoops Software Engineer _ Neutralize (*\*) Independent Online Marketing Services T/F: +44 (0)1209 210910 E: [EMAIL PROTECTED] U: http://www.neutralize.com _ The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this by persons or entities other than the intended recipient is prohibited. If you receive this in error, please contact the sender and delete the material from any computer. The contents of an attachment to this e-mail may contain software viruses which could damage your own computer system. While NUERA Limited has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening the attachment. -Original Message- From: David Robley [mailto:[EMAIL PROTECTED]] Sent: 05 July 2001 03:48 To: [EMAIL PROTECTED] Subject: Re: Insert queries add TWO records to database On Wed, 4 Jul 2001 21:22, you wrote: I think I saw on the mysql list you had pinned this problem on IE? -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Beam me up Scotty. This isn't the men's room. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php