question about writing to files
Posted: Wed Jun 08, 2005 2:44 pm
I have an in.php script for my main page in which it keeps track of where each visitor came from with http_referer. When a surfer comes from a referer that I know of, then I write to a file with that info, updating previous entries.
If I have many visitors at one time, could it be possible that the file would be opened and manipulated simultaneously by two or more users, possibly leading to data corruption? I could lock the file, but then I will not be able to get all the data. I'm wondering if this could happen, and if it does happen, how frequently does it occur?
What are some way to prevent this? Would storing my information in a database solve this? (I prefer files as it is often faster and easier to get data)
If I have many visitors at one time, could it be possible that the file would be opened and manipulated simultaneously by two or more users, possibly leading to data corruption? I could lock the file, but then I will not be able to get all the data. I'm wondering if this could happen, and if it does happen, how frequently does it occur?
What are some way to prevent this? Would storing my information in a database solve this? (I prefer files as it is often faster and easier to get data)