dongshi1188 2013-09-21 16:11
浏览 97
已采纳

PHP注意:未定义的变量

I'm trying to bring a old script that was encrypted and shut down back to life but i'm not the best at php but practice makes prefect.

I've just decoded it and going though the installation process and i'm getting PHP Notices Undefined variable.

[21-Sep-2013 17:51:56 Europe/Berlin] PHP Notice:  Undefined variable: dberror in C:\xampp\htdocs\install\step1.php on line 7
[21-Sep-2013 17:51:56 Europe/Berlin] PHP Notice:  Undefined variable: dberror in C:\xampp\htdocs\install\step1.php on line 10


  <?php

     if (isset($setdb)) {
          if (( ( ( $dbhost && $dbuser ) && $dbpass ) && $dbname )) {
              ( @mysql_connect( $dbhost, $dbuser, $dbpass ) || $dberror = 'Can\'t connect to database server' );

               if (!$dberror) {
               ( @mysql_select_db( $dbname ) || $dberror = 'Can\'t select database' );

                     if (!$dberror) {
                         @session_register( 'dbhost' );
                         @session_register( 'dbuser' );
                         @session_register( 'dbpass' );
                         @session_register( 'dbname' );
                         $_SESSION['dbhost'] = $dbhost;
                         $_SESSION['dbuser'] = $dbuser;
                         $_SESSION['dbpass'] = $dbpass;
                         $_SESSION['dbname'] = $dbname;
                         print '<script> window.location=\'index.php?menu=step2\';  </script>';
                      }
                   }
               }
         else {
              $dberror = 'All fields are required';
      }
  }

Could someone tell me what is wrong please.

  • 写回答

2条回答 默认 最新

  • duansao6776 2013-09-21 16:13
    关注

    This is because if no error occurs, $dberror is never defined.

    if (!$dberror) {
    

    should be:

    if (!isset($dberror)) {
    

    OR

    Add this to the top of the page (recommended):

    $dberror = false;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python验证码滑块图像识别
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)