PHP counter acting weired!
Posted: Thu Jun 19, 2008 2:36 pm
Hi,
I have a simple php script that is suppose to write the number of page loads into a txt file, it works fine, but it doesn't right ANYTHING into the txt file, it just keeps counting away even when there's no txt file on the server!!
Here is the code I am currently using:
You can see the counter in action down the bottom of this page, next to the audio player: http://s244087696.onlinehome.us/hillsviewtrio/
And there is currently NO txt file!
I have a simple php script that is suppose to write the number of page loads into a txt file, it works fine, but it doesn't right ANYTHING into the txt file, it just keeps counting away even when there's no txt file on the server!!
Here is the code I am currently using:
Code: Select all
<?
$counter_file = ("hits.txt");
$visits = file($counter_file);
$visits[0]++;
$fp = fopen($counter_file , "w");
fputs($fp , "$visits[0]");
fclose($fp);
print $visits[0];
?>And there is currently NO txt file!