I've a poll script that allows web users to vote. For any one poll, a data file (txt file) is created to keep track of the poll options and the number of votes received. However, if 2 users access the file at the same time, the data file will be over-written and its content will become blank.

Anyone knows how I can solve this problem? Quite a lot of people access the poll, and this problem has occurred 3 times yesterday.

I tried using the suggested statements, but I get an "Internal Server Error" very often. How can I get around this? Is it because someone is trying to access the locked file? Can someone enlighten me on this?

You should go to the begginers forum and under the topic "help :)" i posted a script from a site that is called server check, it will list out the modules installed on your server. Get that & run it to see if "Fcntl" is on your server. If it isn't then their are different ways of locking files that I can research for you.

Also, make sure that you have permissions on the directory that your script is in set to 773, so that the script can write to the directory, I doubt it's that though.