苍鹰 发表于 2003-10-13 21:21:25

php的问题啊

1.php内容如下:
<html>
<head>
<title>网页计数器</title>
</head>
<body>
&lt;?
//数字输出的网页计数器
$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);
?&gt;
</body>
&lt;/html&gt;
可是我从浏览器里浏览的话得到以下结果:
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
为什么?多谢

jiangtao9999 发表于 2003-10-14 14:22:51

Permission denied :权限不够
解决方法:
1、新建本文件,修改文件权限为 0666
2、修改本目录属性为 0666
3、将本文件夹或文件的所有者设为服务器所使用的用户(一般为nobody)
4、修改服务器所使用的用户

苍鹰 发表于 2003-10-22 16:57:03

恩.可以了多谢
页: [1]
查看完整版本: php的问题啊