I have a page called addrecord.php. there is a script to check if the email going to be added is already in the database, if it is, then you cannot add the same email to the database.
This script runs fine. It never has a problem.
But now this happens.
I was updating this page, addrecord.php, and also I was on the database (direct non web client/serveraccess) too.
And at the same time, a staff is trying to add a record through the web page, by calling addrecord.php, and he got these errors.
he got an error shows: "divided by zero" and i didn't have any divided execution in this page.
also when he tried again, this page is very slow to response but at the same time, other pages of the same site is fine.
when he finally went through, three same new records with the same e-mail address showed. but my code is very clear to check the duplication first, only it is no duplication, add sql statement will be executed. so there is no way, it could have the records with the same email address. but now it happend. (i didn't set up the database constraint here. i enforce it in my php scripts.)
then, everything seems fine. the email duplication is working. the page response quickly.
Obviously, an interruption happend here and cause the problem. I am trying to pinpoint it out how it happens.
1)
i was updating the addrecord.php and he was using it at the same time, i thought, updating or using it would only take a blink to happen. so it will not have conflicts. am i wrong? is the the reason we have the problems?
is it because while he was using the page, and i was updating it. it cause the conflict that make this page hung on there, response to the requests slowly, and three of his tries were hung on there, and due to these tries were not finished, so no previous email address in the database, so all of them pass the duplication checking but hung on there wait to be added. when the server finally solve the conflicts (i also run from linux to kill the dead threads at the same time.) all three request went through. so the three same e-mail address records got into the database?
2)
or it is because i was on the database through my database terminal. But I was only check the table structure, and check the data. No changes made. I think this should not cause the problem.
Please help. I need to pinpoint the problem so I will know that it is not a regular thing.
My best guess is that it is due to I am updating the page and another staff is using the page. Am I right? If that is so, I will try to avoild it? or better advice?
Thanks.