I need a litte help getting this simple hit counter to work on one of my web pages. My "counter.php" file contains only the following code:
<?php
$filename = "counter.txt" ;
$fp = fopen($filename,"r") or die ("Can't open $filename") ;
$fstring = fread($fp, filesize($filename)) ;
echo "$fstring" ;
fclose($fp) ;
$fp1 = fopen($filename,"w") or die ("Can't open $filename") ;
$fcounted = $fstring + 1 ;
$fout = fwrite($fp1,$fcounted) ;
fclose($fp1) ;
?>
The web page where I am trying to show the number of hits contains this code:
<p align="center"><font color="#2E8B57">Page Hits: <font color="ff0000">
<script language="JavaScript" src="http://www.mywebsite.com/counter.php" type="text/javascript">
<!--//-->
</script>
</font></p>
I get no error messages, just no hit number on my web page. The "counter.txt" file contains only one number and it does increment upward each time the web page gets a hit. I have tried taking out the quotes around the $fstring in the echo statement, but that didn't help.