Delayed transactions INSERT/UPDATE with PHP

I have a PHP script on our internet server that sends either an INSERT or UPDATE SQL statement to a table in a small local database. I've tried this with mySQL and Postgress but get exactly the same weird effect.

Firstly, my PC based app sends the data to the PHP script which loads it into the table every 10 seconds in a sequence of about 50 transactions. I then close the app.

In the following hour new records are magically inserted or updated even though nothing is calling the PHP script.

I can only assume that PHP transactions that were made have somehow been delayed by up to an hour coming in randomly, out of sequence, every few minutes and changing the table.

Any help with understanding what's going on and how to solve it much appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It would take some additional details to figure out what is going wrong here.

Specifically, I need more detail on what is meant here: "my PC based app sends the data to the PHP script which loads it into the table every 10 seconds in a sequence of about 50 transactions. I then close the app. "

(1) It's not clear to me how your "PC based app" sends data.
(2) The PHP on the server runs the SQL queries? [i.e. not your PC based app]
(3) What starts the PC-based app?

With just what you've stated, I can say the following:
(1) Neither PHP nor MySQL randomly do things out of order or wait for hours.
(2) This means either (a) something is taking a significant amount of time [like transferring large data or extremely complex processing is causing some entries to appear later] or (b) something else is writing to the database or (c) there's an out of order execution happening where it is not that data happens late so much as data and processing cross awkwardly.
> .. new records ..
are these records with the same data as already added?

I assume that your clients (browser) sends the same request again and again, for example if a browser is restarted
ChrisJonesLycosAuthor Commented:
I've been doing more testing in the meantime so I'll put the results here and hopefully answer some of the requests for more info above. To clarify one point before I begin, the PC based app sends the data to the php script via a .php?QUERY_STRING. The data it's sending is only 4 fields with minimal data.

The sequence I've now followed in testing is:

1. I have an empty table. Via the php script I INSERT one record:
UserID: int; DateTime stamp; Duration: int; DocumentName: varchar(100)

2. Every 10 seconds after that an UPDATE query, sent via the php script, updates the Duration field by 10 seconds. It does this 30 times. After each UPDATE I do a SELECT query on that record and the database reports that the information updated is in fact there.

3. I then close any app or anything else that can talk to the database. I do a DELETE FROM myTable. To double check it's empty I do a SELECT * FROM myTable and it reports no rows.

4. I then at 2 or 3 minute intervals over the next hour do a SELECT * FROM myTable. Each time I do a select, random values from the sequence of 30 updates appear. There is no particular order or sequence to them. Finally, they settle down to a value that does not change. It's usually somewhere in the middle of the sequence.

I think from this I can surmise that it is in fact not the PHP scripts being delayed: an update on an empty table would not produce a record. It seems more like inexplicable behaviour of the database. However, what I cannot fathom is that I have set this up on both mySQL and Postgres and get exactly the same behaviour. The server is not ours, we rent the space on it so I am a bit vague about the underlying setup.
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

How are you doing the later selects (i.e. your step 4)?

i.e. are you using an ODBC connector, MS Access, phpmyadmin, or some other means?

I can imagine either an issue with cached DB results due to a faulty connector OR a system where in fact they are using a large number of slave copies of the database that are delayed in getting the updates.
ChrisJonesLycosAuthor Commented:
The step 4 SELECTs are done using myPHPAdmin or myPGAdmin in either case.

Whatever ends up there after about an hour becomes the permanent state of the table, that's to say, even following the DELETE FROM an hour later there will be a permanent record in the table that then doesn't change.
earth man2Commented:
when does the commit happen ?
if you use SHOW CONNECTION  in phpMyAdmin, are there any connections open at the time?
ChrisJonesLycosAuthor Commented:
I've turned off AUTOCOMMIT and I do an explicit commit in the php directly following the INSERT/UPDATE.

If I do SHOW STATUS in phpMyAdmin and check Threads_connected it says 1 both during the process and following it.
ChrisJonesLycosAuthor Commented:
This bug is easily duplicatable and it's obviously some horribly bodged coding somewhere in the php interpreter.

I've finally resolved it simply by using POST rather than GET as the method for transferring data to the php script.

I'm canceling my subscription to this site as questions like this never get answered.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChrisJonesLycosAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.