So I have this code for a simple hit counter:
Code:
<?php
$COUNT_FILE = "hitcounter.dat";
if (file_exists($COUNT_FILE)) {
$fp = fopen("$COUNT_FILE", "r+");
flock($fp, 1);
$count = fgets($fp, 4096);
$count += 1;
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
} else {
echo "Error - Cannot find file";
}
?>
<center>This page has been viewed <b><?php echo $count; ?></b> times<br></center> This file is in a directory with the file hitcounter.dat, which contains the number 0.
On my index page I have:
Code:
<?php
include("scripts/count.php");
?> So all the files are in the right places, and named corectaly, but It keeps returning the 'Error - Cannot find file' message.
Can anyone spot an error in the code or anythign?
thanks in advice!
Jam