Hi,
this is the same script, rewritten to do locking correctly...
<?php<br><br>$filename = "PHPCounter.txt"; // text file to write to (make sure to change permissions).<br><br>// Opens a new file for first reading, then writing to (fp is short for file pointer, although it can be named anything).<br>// this reads the current count from the file.<br>$fp = fopen( $filename,"r+");<br>// lock the file - this will wait until noone else has a lock<br>flock($fp, LOCK_EX);<br>$Old = fgets($fp);<br><br>// Split the current data where there is an equal sign<br>$Old = split ("=", $Old, 5);<br><br>// Increment the old count from the file by 1.<br>$NewCount = $Old[1] + 1;<br><br>$New = "Count=$NewCount";<br><br>// time to rewrite the file, so rewind to the beginning<br>fseek($fp, 0, SEEK_SET);<br>fputs($fp, $New);<br>// release the lock<br>flock($fp, LOCK_UN);<br>fclose( $fp );<br><br>// Finally print the new count out so the flash movie can read the number in.<br>print "Count=$NewCount";<br><br>?>
Musicman