Ok, I have a script that's basically a counter, and I get it to display, but it doesn't store the "hits." instead it just stays at the same number all the time. Here's the script if anyone can help me.
<?php $counterfile = $DOCUMENT_ROOT.'/counter/'.ereg_replace( "/", "_", $PHP_SELF);
if (!file_exists($counterfile)) {
// Start Counter at 5000
$count=4999; //Will get ++ before being printed
$initial = $count + 1;
}
else {
// Open Counter
//open the file handler
$fp=fopen("$counterfile","r");
//Read the previous count
$count=fgets($fp,1024);
//close the file.
fclose($fp);
}
$fw=fopen("$counterfile","w");
//Increment the counter
$pageviews=$count+1;
//write the counter back to the log file ie., acc.txt
$countnew=fputs($fw,$count+1);
//Display counter
if ($display != "Yes") {
echo $pageviews;
} else {
echo "<!-- This page has been viewed $pageviews times. -->";
}
fclose($fw);
?>