编程论坛's Archiver

yc12 发表于 2007-2-6 17:05

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

<P>&lt;?php<BR>    function counter()<BR>    {<BR>        $max_len = 8;<BR>        $counterfile = "../zzx.txt";<BR>        if(!file_exists($counterfile))<BR>        {<BR>            <FONT color=#ff3300>$counter = 0;</FONT><BR>            $cf = fopen($counterfile,"w");<BR>            flock($cf,3);<BR>            fputs($cf,"0");<BR>            fclose($cf);<BR>        }<BR>        else<BR>        {<BR>            $cf = fopen($counterfile,"r");<BR>            flock($cf,3);<BR>           <FONT color=#f70909> $counter = trim(fgets($cf,$max_len))+0;</FONT><BR>            fclose($cf);<BR>        }<BR>    }<BR>    if(session_is_registered("in")==false)<BR>    {<BR>        $counter=$counter+1;  <FONT color=#0000ff>//这里是24行;<BR></FONT>        $cf = fopen($counterfile,"w");<BR>        flock($cf,3);<BR>        fputs($cf,$counter);<BR>        fclose($cf);<BR>    }<BR>    $counter_len = strlen($counter);<BR>    for($i=1;$i&lt;=($max_len-$counter_len);$i++)<BR>    {<BR>        echo "&lt;img src='image/0.GIF'&gt;";<BR>    }<BR>    for($i=1;$i&lt;=$counter_len;$i++)<BR>    {<BR>        echo "&lt;img src='image/".substr($counter,$i-1,1).".GIF&gt;'";<BR>    }</P>
<P><BR>?&gt;<BR><BR>错误:====<BR>Notice: Undefined variable: counter in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 24</P>
<P>Notice: Undefined variable: counterfile in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 25</P>
<P>Warning: flock(): supplied argument is not a valid stream resource in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 26</P>
<P>Warning: fputs(): supplied argument is not a valid stream resource in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 27</P>
<P>Warning: fclose(): supplied argument is not a valid stream resource in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 28</P>
<P>Notice: Undefined variable: max_len in d:\usr\www\html\phpexe\jishuqi\counter\tqjsq_do.php on line 31<BR>&lt;img src='image/1.GIF&gt;'<BR>是counter变量没有值么??应该不会吧!!麻烦大家看看!!</P>

yc12 发表于 2007-2-6 17:36

问题解决了!!自己又重新写了一遍就好了!!!!<br>麻烦大家能够看看这个帖子的问题,谢谢了!!<br>http://bbs.bc-cn.net/viewthread.php?tid=119739

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.