Page 1 of 1

what do i do if more then 1 user tries to write to a file???

Posted: Wed Sep 18, 2002 6:26 am
by pelegk
i am doing a simple "database" but doing it by using a simple txt file!
what i insert is 2 simple things :
number (11111111) and another number 101010111001
i am inserting them by order and i need to update them evry time!
my question is what will happend if more then 1 user at a time tries to send me data at the same time and the php script will try to access the file
while another 1 hold's it!
how can i prevent it?
what to do?
H E L P :(
thanks in advance
Pelegk

Posted: Wed Sep 18, 2002 6:31 am
by jason
http://www.php.net/flock

Look into locking the file.

Posted: Wed Sep 18, 2002 3:12 pm
by Takuma
Best to use database... Much simpler.

Posted: Wed Sep 18, 2002 3:33 pm
by ~J~R~R
Yes, always use mysql_* first, then file() and then f_*

Posted: Wed Sep 18, 2002 3:37 pm
by Takuma
What I'll do is instead of saving the data in a file save it in a database. Then it'll be much easier to control, and it'll also be faster... 8)