Ben
November 4th, 2003, 20:14
Hey,
I'm learning php, and just for a little practice I tried to make a small page hit counter. Only it tells me there's a parse error on line 33. I can't figure out what's wrong. Anyone have any ideas?
Here's line 33:
if($count >= 0) {
...and here's the rest of the script:
<?php
/*
hit counter
count.php
by Ben
This counter only counts
TOTAL hits. It does not
distinguish between unique
and continuing visits.
*/
///////////////////////////////////
//[Leave this section alone] //
//get the file name //
//$id = $PATH_TO_DIR.$id; // <--forgot to take that out
///////////////////////////////////
//This is the beginning hit count.
//You can cheat by changing it.
//I'll leave it at zero
$count = "0";
//Don't change anything except
//the starting hit count!
//the count file holds the number of hits.
$count_file = "count.txt"
//add a count
if($count >= 0) {
$count++;
}
//this is where all the
//good stuff gets written
$file = fopen($count_file, "w+");
fwrite($file, $count);
fclose($file)
?>
I forgot to mention, It's called to the page you want to count hits on using PHP includes.
Thanks!
Ben
I'm learning php, and just for a little practice I tried to make a small page hit counter. Only it tells me there's a parse error on line 33. I can't figure out what's wrong. Anyone have any ideas?
Here's line 33:
if($count >= 0) {
...and here's the rest of the script:
<?php
/*
hit counter
count.php
by Ben
This counter only counts
TOTAL hits. It does not
distinguish between unique
and continuing visits.
*/
///////////////////////////////////
//[Leave this section alone] //
//get the file name //
//$id = $PATH_TO_DIR.$id; // <--forgot to take that out
///////////////////////////////////
//This is the beginning hit count.
//You can cheat by changing it.
//I'll leave it at zero
$count = "0";
//Don't change anything except
//the starting hit count!
//the count file holds the number of hits.
$count_file = "count.txt"
//add a count
if($count >= 0) {
$count++;
}
//this is where all the
//good stuff gets written
$file = fopen($count_file, "w+");
fwrite($file, $count);
fclose($file)
?>
I forgot to mention, It's called to the page you want to count hits on using PHP includes.
Thanks!
Ben