On Sun, 02 Aug 2009 07:11:27 +0300, "Parham Doustdar" <parha...@gmail.com>
wrote:
Dear Ollisso,
I tried it with FLock() but it still didn't work. This is what I did:
[code]
$fp = fopen($f, "r");
$count =fgets($fp, 1024);
fclose($fp);
$fw = fopen($f, "w");
while (!flock($fw, LOCK_EX))
sleep(1);
$cnew = $count + 1;
$countnew = fputs($fw, $count + 1);
flock($fw, LOCK_UN);
fclose($fw);
[/code]
Am I doing anything wrong here?
Thanks!
Hello,
Actually you should do something like this (according to manual)
$f=fopen("file", "r+");
while(!flock($f, LOCK_EX)) sleep(1);
$count = fgets($f,1024);
ftruncate($f, 0);
fwrite($f, $count+1);
fclose($f);
Problem in your case: first time you open file for reading, but you don't
flock it, so it can read non-writen file.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php