Jump to content

Multiple users fwriting at once?


Allenph9

Recommended Posts

I am basically done with my entire site. I just realized...what happens if 10 users are trying to fwrite to one file at once? that is how i store my usernames passwords signatures and all that jazz. If users cant all fwrite at once my site is not going to work AT ALL. and I might just have to give up haha. good news or bad news?

Link to comment
https://forums.phpfreaks.com/topic/258634-multiple-users-fwriting-at-once/
Share on other sites

Considering the flak we gave you for the other one, I'll try to be nicer.

 

It's possible if you use file locking but know that there are situations where it will not work. Basically you open the file, lock it so that other processes can't read from it, do your work, then unlock and close.

File locking

flock

file_put_contents can lock starting with PHP 5.1

 

However this is another one of those things that you really should fix, especially given that you'd have to implement the locking logic everywhere you read from or write to a file anyways. Even giving you some credit for dealing with the other problem isn't enough to deal with this particular issue. It will cause problems. Databases are much easier to deal with and are definitely worth the additional time to learn and use and you don't have to worry about any of this locking nonsense.

Well I HIGHLY doubt that I will have multiple users doing anything at once for a good long while since this will be my first site. Ill slowly work in the database...I already have mysql installed but at the time it seemed like a good idea...sites done...thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.