在两个函数的里面加上
global $conn;
因为$conn是全局变量,在函数内部不可见。

解决方案 »

  1.   

    可以不加,你可以检查下:
    1:可能是require ('config.php')里没有连接上;
    2:是不是在程序的某部分有运行mysql_close($yourlink);
    3:或者最后一次使用的连接是别的数据库;
      

  2.   

    加上global就可以了。楼上的你要负责任的,测试一下再说好吗。
    他明显是变量$conn的作用域问题嘛
      

  3.   

    不对啊?出现这样的的错误“Directory Listing Denied
    This Virtual Directory does not allow contents to be listed.”
    <?
    require ('config.php');//require ('config.php'); //联接数据库
    require ('sessionconfig.php') //关于session的检验
    $id=$_GET[id];
    $action=$_GET[action];
    $referer=$_SERVER['HTTP_REFERER'];
    switch ($action){
    case "showno":
          showno();
          break; 
        case "showyes":
          showyes();
          break; 
       default:
    header("Location:$referer");
    break;}
    function showno(){
    global $conn;
    $sql="UPDATE `article` SET `ifshow` = '0' WHERE `id` = '$id' LIMIT 1;" ;
             mysql_query($sql,$conn) or die("操作失败:".mysql_error());
     header("Location:$referer");
     
    }
    function showyes(){
    global $conn;
    $sql="UPDATE `article` SET `ifshow` = '1' WHERE `id` = '$id' LIMIT 1;" ;
             mysql_query($sql,$conn) or die("操作失败:".mysql_error());
     header("Location:$referer");
     
    }
    ?>
      

  4.   

    网上查了下,Directory Listing Denied
    This Virtual Directory does not allow contents to be listed
    错误原因是:
    您站点的目录上没有找到首页文件