Preventing multiple users from writing to the same 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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Preventing multiple users from writing to the same file.

Post by neophyte »

I've been trying to figure out how to prevent multiple users from writing to the same file at once -- if that causes a conflict. Anybody know how to write a script that would enable multiple users writing to this file to write to it all at once? I've been doing some reading... Does flock() have something to do with it? If more than one person tries to write to this file will they que up or will they die?

else if (!empty($newlink)){
if ($error == "OOPS!<br>"){
$fp=fopen($filename, 'a+');
fwrite ($fp, $cleanlink);
print "<b> Your link:</b> ".str_replace("|","", $cleanlink);
}
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

I guess it must be imossible

Post by neophyte »

I guess it must be impossible... Or maybe too much.... Whatever.
Post Reply