Allenph9 Posted March 10, 2012 Share Posted March 10, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/258634-multiple-users-fwriting-at-once/ Share on other sites More sharing options...
requinix Posted March 10, 2012 Share Posted March 10, 2012 Bad news. You should be storing all this stuff in a database, not flat files (as it's called). Quote Link to comment https://forums.phpfreaks.com/topic/258634-multiple-users-fwriting-at-once/#findComment-1325776 Share on other sites More sharing options...
Allenph9 Posted March 10, 2012 Author Share Posted March 10, 2012 Ya I knew i technically should be but...will it work? I dont want its bad form and all that jazz but will it work? Quote Link to comment https://forums.phpfreaks.com/topic/258634-multiple-users-fwriting-at-once/#findComment-1325778 Share on other sites More sharing options...
requinix Posted March 10, 2012 Share Posted March 10, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258634-multiple-users-fwriting-at-once/#findComment-1325783 Share on other sites More sharing options...
Allenph9 Posted March 10, 2012 Author Share Posted March 10, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258634-multiple-users-fwriting-at-once/#findComment-1325787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.