View Single Post
  #1 (permalink)  
Old 08-11-2008, 12:44 PM
Jam's Avatar
Jam Jam is offline
CompuForums Moderator
 
Join Date: 02 Mar 2008
Location: In My Own Little World
Posts: 655
Jam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond reputeJam has a reputation beyond repute
Default PHP Hit Counter Problem

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
__________________
Help Support CompuForums, And Become a Premium Member today! -

- Advert Free - Increased PM Storage - Increased Avatar Size - Colored User Name (To Set You Apart From Other Members!) - And Access To The Premium Members Only Forum! -

Your Donations Help Keeps CompuForums Alive!
_______________________________________
Anyone who isn't confused here doesn't
really understand what's
going on


JamsUbuntu.blogspot.com
Reply With Quote
Sponsored Links