Hi All,

I have a problem with a high traffic (mysql) script page.
What the script does is archive users that have expired according to time used up. The "sessionaccounting" table can have 1 to thousands of enties (24 columns) for a single user.
What's happening is that sometimes when records are moved the script bails out and doesnt move data from all of the tables.

I suspect that this is caused by concourant hits to the script ie.. the script is archiving a lot of records and the in the middle of archiving the script gets called again.

Here is the code
$q1= "INSERT into asessionaccounting  select * FROM sessionaccounting where UserName = '" . $row['UserName'] . "' ";
$update1 = mysql_query($q1) or die(mysql_error());

// there are seven more similar inser/select queries here
//then the delete (seven more of these)

$qd1= "DELETE FROM sessionaccounting WHERE UserName = '" . $row['UserName'] . "' ";
$updated1 = mysql_query($qd1) or die(mysql_error());
The problem is that sometimes a complete archive does not happen.
Does anyone have any ideas as to what may be happening and more importantly how can it be fixed.

Many Thanks