Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file locking help

Status
Not open for further replies.

iostream71

Programmer
Mar 13, 2002
229
US
i have a guestbook flash animation that reads and writes to a text file via php script

my problem is, if i do a write to the text file, sometimes the flash movie reads the text file before it's written to(when you post a message, it writes to the file, them reads it)

is there any way i can lock the file to prevent reading until the write is completed?
 
Your flash app is submitting data to a PHP script, which then appends the new text to the file, then returns the new total file, right? ______________________________________________________________________
Perfection in engineering does not happen when there is nothing more to add.
Rather it happens when there is nothing more to take away.
 
well, it basically takes the old posts, splits them up into separate posts(an array), then writes back the last 10 to the same file. hope that makes sense
 
Okay. But the same script accepts the input, edits the file, then returns the postings right?

I mean your Flash script does not hit one CGI to submit, then another to get the last 10 posts, right? ______________________________________________________________________
Perfection in engineering does not happen when there is nothing more to add.
Rather it happens when there is nothing more to take away.
 
that's right, one script handles all the reading writing
 
read up on flock
be aware of the warning about O/S dependancy.

You may have to consider read/write to a temp file and then destroying the old and recreate with new.

For this you will need copy() and unlink() ***************************************
Party on, dudes!
[cannon]
 
flock might be able to solve your problem.

A solution you also might want to explore is to store your guestbook entries to a MySQL database. ______________________________________________________________________
Perfection in engineering does not happen when there is nothing more to add.
Rather it happens when there is nothing more to take away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top