把这一句去掉
exec( "rm -rf $counterFile");
或者换成:
exec( "deltree/y $counterFile");谁给我加分数呀?

解决方案 »

  1.   

    忘了一点,偶的也出现dos窗口,98和nt下都是,估计是不治之症。
      

  2.   

    为什么不用PHP自己带的函数DELETE()呢?
      

  3.   

    唉,各位大哥大,还是不行呀,调用的话会死机呀
    唉,我的是PWS+PHP4。0的了
    我看是说不清楚了,你们那位也是WINDOWS下的PHP
    能不能把你的PHP程序,不管有多简单,有多
    请你发我一份好吗??
    我真的很想学PHP
    可是网上的资料很少,就是有,也是FOR LINUX的,我这单机总不可能格了装LINUX吧
    我的E-MAIL是
    [email protected]
    谢谢了,谢谢
    希望你们能帮帮我!
       一个PHP的爱好者!
      

  4.   

    抱歉,我先前用的是php3.0.15+win98+pws。
    现在用的是nt+iis4.0+php4。
    结果也出现先前的计数器程序不能运行。
    偶发现php的文件好像只能分别打开读或写,而不能一次打开,同时读写。
    偶改了一下程序,铁上来。
    <?php
    #######################################
    //计数器
    #######################################
    function DisplayCounter($File){
     
      $fp=fopen($File,"r");
      $num=fread($fp,5);
      fclose($fp);
      $fp=fopen($File,"w");
      $num+=1;
      //exec("echo $num >$File");
      $b=fwrite($fp,$num);
      echo "<br>您是第".$num."位无聊人士\n";
      fclose($fp);
    } $CounterFile="counter.txt"; 
      
     if(!file_exists($CounterFile)){
       $fp=fopen($CounterFile,"w");
       fwrite($fp,"0");
       //exec("echo 0 >$CounterFile");
      }
     DisplayCounter($CounterFile);  
     
    #######################################
    ?>否则,偶的程序会出现:
    Warning: Unable to fork [echo 0 >counter.txt] in d:\inet\www\test.php on line 21偶也不知道为什么。就这样。
      

  5.   

    还是不行呀!不知道有这么多人说PHP的长PHP的短,难道 
    都是空对空吗??有没有的是干 实例的!
      

  6.   

    <?
    #读取文件
    $fp=fopen("counter.txt","r+");
    $num=fgets($fp,10);
    rewind($fp);
    $num++;
    fputs($fp,$num);
    if($num<10)$num="00".$num;
    else $num="0".$num;
    fclose($fp);#输出图形
    Header("Content-type:image/gif");
    //dl("php3_gd.dll");
    $img=imagecreate(350,30);
    $bg=ImageColorAllocate($img,0,0,0);
    $fg=ImageColorAllocate($img,255,255,255);
    $nu=ImageColorAllocate($img,200,225,255);
    $mo=ImageColorAllocate($img,255,120,120);
    ImageString($img,5,5,6,"Welcome,you're the       people!",$fg);
    ImageString($img,5,175,6,$num."th",$nu);
    ImageArc($img,320,9,20,20,35,190,$mo);
    ImageGif($img);
    ImageDestroy($img);
    ?>
    简单的图形计数器
      

  7.   

    上面的程序没有判断counter.txt文件不存在的情况。自己加上就可以了!
      

  8.   

    <html>
    <head>
    <title>访客计数器 原型</title>
    </head>
    <body>
    <?php
    /*
    simple access counter for php3
    (c)1998 David W. Bettis
    [email protected]
    medify by Wilson Peng
    *///!!!!!!!!!!!改成一个存在的目录
    //$counterFile =  "/tmp/counter.txt";
    $counterFile="counter.txt";function displayCounter($counterFile) {if (!file_exists($counterFile)) {
      $num=1;
      }
    else
    {
    //!!!!!!!!不要又读又写  $fp    = fopen($counterFile,"rw");
      $fp=fopen($counterFile, "r");
      $num    = fgets($fp,5);
      $num    += 1;
      //将写入分开
      fclose($fp);
    }
      print  "您是第 "."$num"." 位无聊份子";
    //  exec( "rm -rf $counterFile");
    //  exec( "echo $num > $counterFile");
    //用函数完成写入
      $fp=fopen($counterFile, "w");
      fputs($fp, "$num");
      fclose($fp);
    }//!!!!!!!移到前面去了 if (!file_exists($counterFile)) {
    //  exec( "echo 0 > $counterFile");
    }displayCounter($counterFile);?>
    </body>
    </html>