PDA

View Full Version : function.open error --PHP



randycgaz
July 18th, 2003, 09:18
Warning: fopen(xcounter.txt) [function.fopen]: failed to create stream: Permission denied in /home/refined/public_html/amnews/index.php on line 4

Warning: fread(): supplied argument is not a valid stream resource in /home/refined/public_html/amnews/index.php on line 5

Warning: fclose(): supplied argument is not a valid stream resource in /home/refined/public_html/amnews/index.php on line 6

Warning: fopen(xcounter.txt) [function.fopen]: failed to create stream: Permission denied in /home/refined/public_html/amnews/index.php on line 9

Warning: fwrite(): supplied argument is not a valid stream resource in /home/refined/public_html/amnews/index.php on line 10

Warning: fclose(): supplied argument is not a valid stream resource in /home/refined/public_html/amnews/index.php on line 11
---------------------------

This counter is what the above error is referring to.
I need to set permissions to r+. But how?


<?php
$file = "xcounter.txt";
unset($h);
$f = fopen($file, "r+");
$h = fread($f, filesize($file));
fclose($f);
if (!$mevisit) {
$h++;
$f = fopen($file, "w+");
fwrite($f, $h);
fclose($f);
@setcookie("mevisit","yes",time()+31536000);
}
?>

kabatak
July 18th, 2003, 15:29
if you hav ftp, you can chmod the file to 777.

randycgaz
July 21st, 2003, 12:25
The free web hoster I'm using does not allow ftp.
Now what?

kabatak
July 21st, 2003, 12:32
try making a php file with this code and run it once. if it doesnt work, no choice but to ask your server admin to chmod it for you.


<?php
chmod ("xcounter.txt", 0777);
echo ('chmod successful');
?>

keith
July 21st, 2003, 19:02
this will tell you whether or not it's mode is able to be changed:

<?php

if (chmod("xcounter.txt", 0666))
echo "chmod was successful";
else
echo "chmod was *not* successful";

?>

randycgaz
July 23rd, 2003, 11:47
Thanks much.

It worked like a charm.

It did not echo the "chmod was successful" line though, just displayed the text file file with the counter number.

Thanks again.