php的问题啊
1.php内容如下:<html>
<head>
<title>网页计数器</title>
</head>
<body>
<?
//数字输出的网页计数器
$max_len=8;
$CounterFile="counter.dat";
if(!file_exists($CounterFile))
{$counter=0;
$cf=fopen($CounterFile,"w");
fputs($cf,"0");
fclose($cf);
}
else
{$cf=fopen($CounterFile,"r");
$counter=trim( fgets($cf,$max_len) );
fclose($cf);
}
$counter++;
$cf=fopen($CounterFile,"w");
fputs($cf,$counter);
fclose($cf);
?>
</body>
</html>
可是我从浏览器里浏览的话得到以下结果:
Warning: fopen(counter.txt): failed to open stream: Permission denied in
/home/httpd/1.php on line 12
Warning: fputs(): supplied argument is not a valid stream resource in
/home/httpd/1.php on line 13
Warning: fclose(): supplied argument is not a valid stream resource in
/home/httpd/1.php on line 14
Warning: fopen(counter.txt): failed to open stream: Permission denied in
/home/httpd/1.php on line 22
Warning: fputs(): supplied argument is not a valid stream resource in
/home/httpd/1.php on line 23
Warning: fclose(): supplied argument is not a valid stream resource in
/home/httpd/1.php on line 24
Resource id #2
为什么?多谢 Permission denied :权限不够
解决方法:
1、新建本文件,修改文件权限为 0666
2、修改本目录属性为 0666
3、将本文件夹或文件的所有者设为服务器所使用的用户(一般为nobody)
4、修改服务器所使用的用户 恩.可以了多谢
页:
[1]