Hello Im a little new to debugging PHP.
Can anyone help me debug my PHP Counter script?
It works fine. I think it forgets to count sometimes…
<?php //start PHP script
$COUNT_FILE = "count_data.txt"; //load this txt file as the count file
if (file_exists($COUNT_FILE)) { //if count file exists...
$fp = fopen("$COUNT_FILE", "r+"); //open it
flock($fp, 1);
$count = fgets($fp, 4096);
$count += 1; //add 1
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
$message="$count";
echo "result=$message"; //display Counter result
} else {
$message="???";
echo "result=$message"; //display Error result
}
?> //end php script