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
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.