注册 登录
编程论坛 PHP技术论坛

[求助]自己写的计数器出的问题??

yc12 发布于 2007-02-06 17:05, 958 次点击

<?php
function counter()
{
$max_len = 8;
$counterfile = "../zzx.txt";
if(!file_exists($counterfile))
{
$counter = 0;
$cf = fopen($counterfile,"w");
flock($cf,3);
fputs($cf,"0");
fclose($cf);
}
else
{
$cf = fopen($counterfile,"r");
flock($cf,3);
$counter = trim(fgets($cf,$max_len))+0;
fclose($cf);
}
}
if(session_is_registered("in")==false)
{
$counter=$counter+1; //这里是24行;
$cf = fopen($counterfile,"w");
flock($cf,3);
fputs($cf,$counter);
fclose($cf);
}
$counter_len = strlen($counter);
for($i=1;$i<=($max_len-$counter_len);$i++)
{
echo "<img src='image/0.GIF'>";
}
for($i=1;$i<=$counter_len;$i++)
{
echo "<img src='image/".substr($counter,$i-1,1).".GIF>'";
}


?>

错误:====
Notice: Undefined variable: counter in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 24

Notice: Undefined variable: counterfile in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 25

Warning: flock(): supplied argument is not a valid stream resource in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 26

Warning: fputs(): supplied argument is not a valid stream resource in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 27

Warning: fclose(): supplied argument is not a valid stream resource in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 28

Notice: Undefined variable: max_len in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 31
<img src='image/1.GIF>'
是counter变量没有值么??应该不会吧!!麻烦大家看看!!

1 回复
#2
yc122007-02-06 17:36
问题解决了!!自己又重新写了一遍就好了!!!!
麻烦大家能够看看这个帖子的问题,谢谢了!!
https://bbs.bc-cn.net/viewthread.php?tid=119739
1