This one had me baffled for several hours:
The main script was in the root directory with a database AAA. It was a working script with around 800 members, but it wasn't very busy.
The test script was in root/test with a database BBB and I was the only person with access.
Both databases were virtually identical because I'd only just backed up, but the scripts varied a little.
The test script worked faultlessly but the main script kept throwing up SQL Query Errors claiming there was a duplicate primary key. It was particularly noticeable when members were trying to logon.
I eventually noticed that the test script was being updated. I saw a comment dated just a few hours earlier, then a few messages began to appear. I also discovered that if I logged off from the test script, then logged in on the main script, I was logged in to the test script also.
I renamed the test script's Index.php, then removed the database, but the SQL errors continued on the main database.
As the test database was more or less up-to-date, I deleted the main script and database, redirected the URL to the test script and all the problems went away.
I've always ran test scripts in a sub-directory of the main script and nothing like this has ever happened before.
Any clues?