View Full Version : php/mysql question

16-07-2009, 04:24 PM
if i have a website using php and mysql where the first person to click on a particular button wins a prize, what happens if 10 people click on the button at the exact same time including milliseconds? how does php/mysql pick who clicked the button first?

16-07-2009, 05:08 PM
That depends entirely on how you wrote your script. If you did a good job, then whichever one hits the database first will be the winner. If you did a bad job, then it could be any of them, as you'll run into race conditions. If you did a really bad job you may even get some nice error messages out of it :p.

Edit: To be slightly more specific, it depends on how you implemented your locking / semaphore system.

16-07-2009, 05:35 PM
Unless you have a huge amount of people viewing the site or whatever i wouldnt worry about milliseconds, but as Erayd said if the script was well written then it would be first in first served