Forum Moderators: coopster

Message Too Old, No Replies

Duplication in database caused by script?

php mysql scripting

         

Drunk N Japan

1:37 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



I have instigated a duplication check per an earlier discussion, but now I am getting multiple additions to the data base. Here is an abbreviation of the code I am using.
if((all the variables pass verification)){
dbx_connect();//connect to database function
$duplicate="SELECT * From `table` Where var1 = 'var1eqv' AND ...
$dupe_result=mysql_query($duplicate) or die(mysql_error());
$dupe_rows = mysql_num_rows($dupe_result);
if (!$dupe_rows)
{
//insert non duplicate with status as 3
dbx_connect();
$sqlAR = "INSERT INTO table VALUES ('$null','etc',...)";
$resultAR = mysql_query($sqlAR);
}
else
//if duplicate put 99 as status
{
dbx_connect();
$sqlAR = "INSERT INTO table VALUES ('$null','etc',...)";
$resultAR = mysql_query($sqlAR);
}

For some reason unknown to me I am now getting submissions to the database that are up to 6 in a row, with a difference in time of about 6 seconds. While these extra submissions are being caught as duplicates, they are slowly but surely eating up memory in my database. Could it be that because I have the dbx_connect in there for each read and write phase individually that it is causing this many entries? Also could it be that I am using the same variables in the two different INSERT statements($sqlAR X2) that this is happening? I have changed the form pages to allow only one submit at a time by disabling the button after the first click.
<INPUT name="Submit" onclick="this.disabled=true;document.form2.submit();" type="submit" name="Submit" value="Finish">
I turned on the disable function on one page yesterday and 3 today. I will monitor the pages all day today looking for these kinds of errors. I appreciate any advice y'all can give.

Drunk N Japan

6:17 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



I have tried removing the extra dbx_connects and I am still having multiple posts to the database. Any body have any Ideas?