Hi there,
I've written a counter for my blog, which keeps the count of visitors in a 
file. However, when the visitors get too many, it resets to zero. Why?

Here's the piece of code:

$f = $dir . '/view_counter' .EXT;
$fp = fopen($f, "r");
$count =fgets($fp, 1024);
$fw = fopen($f, "w");
$cnew = $count + 1;
$countnew = fputs($fw, $count + 1);
return $cnew;

I'm thinking this is caused by two visitors visiting the page at the same time; 
but is there a way to fix it, perhaps the reading/writing parameter?


Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com

Reply via email to