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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pelegk
Forum Newbie
Posts: 5
Joined: Wed Sep 18, 2002 6:26 am

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

Post 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
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

http://www.php.net/flock

Look into locking the file.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Best to use database... Much simpler.
User avatar
~J~R~R
Forum Newbie
Posts: 20
Joined: Wed Sep 18, 2002 12:19 pm
Location: Amsterdam, the Netherlanda

Post by ~J~R~R »

Yes, always use mysql_* first, then file() and then f_*
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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)
Post Reply