Jump to content

Duplicate lines incorrectly being inserted


ama

Recommended Posts

I have had a random problem for 3 months now.  I have read literally dozens of forums and have found various answers but no solutions.  I have a php script that includes an insert sql statement that I use with mysql_query.  When I run the script It will insert the line initially, but within 3-4 hours the same record is inserted 2 more times making 3 copies total.  I have run similar scripts on 2 different servers with the same results.  I thought that it was only happening on Mozilla and not on Chrome or IE, but now, I have duplicated it with IE. 

 

I have read people who have had this problem with Mozilla and it had to do with Header information.  I have explored that without success.  I've heard of similar behavior if you have an img tag where src=="", or if you have an error in a css file, then firefox will load the page twice.  I don't believe that is my problem as it happens with IE.  mysql_error() does not output anything.

 

The test table looks as it seems it would.  There is a Text ID, first, last, pos, birth, rookie.  The last 2 are integers and the rest are strings.

 

I also tested it with a VERY simple script (which I am including).  I'm not sure if it is a browser thing, a coding thing, a header thing, a syntax thing.  I am at a loss.  Please help.

 

This is my whole script:

 

<?php
    $mydb = mysql_connect("MY_SERVER", "MY_UN", "MY_PW") or die(mysql_error());
    mysql_select_db("MY_DB") or die(mysql_error());

    mysql_query("INSERT INTO players (ID, first, last, pos, birth, rookie) VALUES ('Test', 'Joe', 'Practice', 'QB', 1990, 1990)") or die(mysql_error());
    echo("done");

?>

 

web Server stats:   

    * Apache

    * MySQL client version: 5.1.47

    * PHP extension: mysqli

 

Mysql stats:

# Server version: 5.1.44-log

# Protocol version: 10

# MySQL charset: UTF-8 Unicode (utf8)

 

I think that is everything the rules asks for.

 

Thanks, Alan

By posting my question, Murphy's law came to my rescue.  After trying to find the solution for 3 months, I finally found the answer the day after posting to the forum.

 

For me, my css file was borrowed from another project I am working on, so naturally there are things that don't apply to this project, but no big deal right?  Well, the css file referenced a background image for a banner.  That background image wasn't in the folder with the new main.css file so when I tried to access the page it would open the css file, then try to find the background image.  When it was unable http threw a 404 then tried again, resubmitting the form.  When I commented out that line, everything worked fine.

 

I hope I can save someone 3 months of their lives by finding this post.

Alan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.