说明没有定义xxxxx,能贴出你的程序吗?

解决方案 »

  1.   

    有点长,是从动网上下载文章管理的,别的很多也有这样的问题。
    出现的页面错误提示为:X-Powered-By: PHP/4.0.3pl1 Content-type: text/html 
    Warning: Undefined variable: typeid in E:\Inetpub\PHP\Article\index.php on line 11
    还有很多和上面一样的错误。
    部分代码如下:
    <html>
    <head>
    <title>PHP专题|http://asky.on.net.cn</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <script language="javascript">
    function popwin2(id,path)
    {                window.open("list.php?id="+id+"&ppath="+path,"","height=450,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
    }
    </script>
    <?
    $typeid=htmlspecialchars ( $typeid );
    if ($typeid==""){
            $typeid=1;
    };$conn = mysql_connect('localhost:3306','root','');
    mysql_select_db('article');
    $text = "select*from type where typeid=$typeid ";
    $rs = mysql_query ($text,$conn);
    $rom = mysql_fetch_row ($rs);
    $err=mysql_error();
    if (! $rom) {
                    echo $err."<br>";
            echo "此栏目不存在!!!!";
            }
    else{
            $page=htmlspecialchars($page);
            if ($page==""){
                    $page=1;
            };
         $type1=$rom[1];
            $text="select count(*) as articleid from learning where typeid='$typeid'";
            $rs=mysql_query($text,$conn);
            $pagesize=2;
            $count=mysql_result($rs,"0","articleid");
            if (!$count){
    …………
    没有全部给出,太长了。
      

  2.   

    错误原因:第十一行($typeid=htmlspecialchars($typeid);)函数htmlspecialchars中的参数$typeid没有定义,所以出错,你可以照下面的方法改正。把$typeid=htmlspecialchars ( $typeid );
    if ($typeid==""){
            $typeid=1;
    };改为:if (not isset($typeid) or $typeid==""){
            $typeid=1;
    }
    else{
            $typeid=htmlspecialchars($typeid);
    }
      

  3.   

    peakcock:php的环境变量是不是部可以自动引用
    书上给出的一个计算器例子如下
    <form action=" <? echo $PHP_SELF ?>" method="post">
    操作数1:<input type=text name=num1><br>
    操作数2:<input type=text name=num2><br>
    <p>
    你希望进行何种操作呢?<br>
    <input type=radio name=operation value="加" checked>加<br>
    <input type=radio name=operation value="减">减<br>
    <input type=radio name=operation value="乘">乘<br>
    <input type=radio name=operation value="除">除<br>
    <input type=submit><input type=reset></form>
    </body>
    </html>
    结果:   <?php echo $num1;?>   <?php echo $operation;?>   <?php echo $num2;?>
    等于<br>
    <h1>
    <?php
    if ($operation ==  "除")
    {$x = $num1 / $num2;
    print $x;}
    elseif ($operation ==  "减")
    {$x = $num1 - $num2;
    print $x;}
    elseif ($operation ==  "乘")
    {$x = $num1 * $num2;
    print $x;}
    else
    {$x = $num1 + $num2;
    print $x;}
    ?>
    </h1>
    _______________________________
    第一次运行结果如下: 
    Warning: Undefined variable: num1 in E:\Inetpub\phproot\chapter08\09.PHP on line 15
    Warning: Undefined variable: operation in E:\Inetpub\phproot\chapter08\09.PHP on line 15
    Warning: Undefined variable: num2 in E:\Inetpub\phproot\chapter08\09.PHP on line 15
    等于
    Warning: Undefined variable: operation in E:\Inetpub\phproot\chapter08\09.PHP on line 19
    Warning: Undefined variable: operation in E:\Inetpub\phproot\chapter08\09.PHP on line 22
    Warning: Undefined variable: operation in E:\Inetpub\phproot\chapter08\09.PHP on line 25
    Warning: Undefined variable: num1 in E:\Inetpub\phproot\chapter08\09.PHP on line 29
    Warning: Undefined variable: num2 in E:\Inetpub\phproot\chapter08\09.PHP on line 29
    0
    ______________________
    是否一定要初始化变量,另外,书上说没有付值的变量为0或空字符,好像不顶用,运行时总是
    出现Undefined Variable
      

  4.   

    估计是你改动了PHP.ini配置文件了,
    原来的版本有个Track_vars,自动为form传来的数据生成变量($num1,$num2等)
    不过php4.0以后这个功能就是自动enable的了,另外还有:register_globals,register_argc_argv估计和你的问题也有关。
    你最好重新copy一个新的Php.ini回去试一试
      

  5.   

    我检查过了,Track_vars自动enable的,
    register_globals=on
    register_argc_argv=on
    不知道怎么搞的?
      

  6.   

    应该不错呀,你的php版本是多少?对php.ini作了哪些改动?