cannot update counter file
Posted: Thu Jun 17, 2004 11:50 am
I have my counter.php file in my root directory.
it has the following code.
But the count_data.txt files doesn't get incremented...
I'm running PHP 4.3.1, Apache 1.3 under win2k
If its in windows the first thing to debug is to check the file permission ..but i'm running only windows??
whats the problem?
it has the following code.
Code: Select all
<?php
$COUNTER_FILE = "count_data.txt";
if (file_exists($COUNTER_FILE))
{
// Open, read, increment, save and close file.
$fp = fopen("$COUNTER_FILE", "r+");
flock($fp, 1);
$count = fgets($fp, 4096);
//echo "<br> count = $count";
$count += 1;
//echo "<br> count = $count";
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
}
else
{
// Create a file with initial data as 1.
$fp = fopen("$COUNTER_FILE", "w");
flock($fp, 1);
$count = fgets($fp, 4096);
if(!$count) $count = 1;
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
}
?>I'm running PHP 4.3.1, Apache 1.3 under win2k
If its in windows the first thing to debug is to check the file permission ..but i'm running only windows??
whats the problem?