Re: page counter

From: Date: Tue, 10 Apr 2001 10:16:53 +0000
Subject: Re: page counter
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47988@lists.php.net to get a copy of this message
In addition of all people said, I would add a lock to the file :
$cf = fopen($counter_file,"w");
flock($cf,LOCK_EX);
fputs($cf, "$counter_file_line[0]"); fclose($cf);
This to avoid another script attempt to read the file while you update it... I had the problem, so sometimes the counter return to zero... jean-arthur At 13:38 10/04/01 +0800, Wen Ni wrote:
I got an example from the internet about the PHP page counter. However after several testing on the coding, I still met the problem which I don't understand. Please help me. <? $counter_file = "/home/venus/public_html/qa/doccon/doc_distribution/count.txt"; $counter_file_line = file($counter_file); $counter_file_line[0]++; print "counter=$counter_file_line\n"; $cf = fopen($counter_file,"w"); fputs($cf, "$counter_file_line[0]"); fclose($cf); echo $counter_file_line[0]; ?> problems: Warning: fopen("/home/venus/public_html/qa/doccon/doc_distribution/count.txt","w") - Permission denied in /home/venus/public_html/qa/doccon/doc_distribution/New.php on line 9 Warning: Unable to find file identifier 0 in /home/venus/public_html/qa/doccon/doc_distribution/New.php on line 10 Warning: Unable to find file identifier 0 in /home/venus/public_html/qa/doccon/doc_distribution/New.php on line 11 ################ Thanks from: Wendy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
---------------------------------------------------------------- EuroVox 4, place Félix Eboue 75583 Paris Cedex 12 Tel : 01 44 67 05 05 Fax : 01 44 67 05 19 Web : http://www.eurovox.fr ----------------------------------------------------------------

« previous php.general (#47988) next »