Hello
I have this counter "system" that's built from a php script and a txt file (set to 0) placed in the same directory.
The script is as follows:
<?php
// path to counter.txt
$counter_file = "./counter.txt";
// Open the file for reading
if (!($fp = fopen($counter_file, "r"))) die ("Cannot Open $counter_file.");
// Read 20 characters from the file
$counter = (int) fread($fp, 20);
// Close the file
fclose($fp);
// Increment the counter
$counter++;
// Display the counter
echo "You are visitor Number $counter.";
// Open the file, in write mode
$fp = fopen($counter_file, "w");
// Write the new value of counter to the file.
fwrite($fp, $counter);
// Close the text file.
fclose($fp);
?>
It reads from the file OK and outputs the digits
For example it writes: You are visitor number 1
The problem is when it tries to open the file in write mode
It outputs the following lines:
Warning: fopen("./counter.txt","w") - Permission denied in /usr/www/users/kisufim/counter/index.php3 on line 16
Warning: Unable to find file identifier 0 in /usr/www/users/kisufim/counter/index.php3 on line 18
Warning: Unable to find file identifier 0 in /usr/www/users/kisufim/counter/index.php3 on line 20