Since 2 days I am trying to start learning more about PHP, not so easy at 62. I installed first separate on windows XP pro SP2 Apache and PHP. It worked fine except that I cannot write to a file from the PHP script. I tried others and now XAMPP. Which really looks very nice and easy to start with. Unfotunately I still have the same problem. This is the testscript:
<?php
error_reporting(E_ALL & E_NOTICE);
$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);
if(fputs($fp, $count)) {
echo "WRITTEN";
flock($fp, 3);
fclose($fp);
}
echo "NOT written";
} else {
echo "Can't find file, check '\$file'<BR>";
}
?>
<center>This page has been viewed <b><?php echo $count; ?></b> times<br>
It is a page view counter. PHP can see the hitcounter.dat file, open it, read it, but cannot write to it. I keep getting "NOT written" and the value is not incremented. I tried through Windows file security to do something, but nothing seems to help. It is also not clear to me who is the user in case PHP or Apache is writing to the file. Searching on the web other people seem to have had the same problem, but I still have not found a solution. Can someone help please... many thanks
You can reply in German if that is more easy. ...