首页 > 解决方案 > 为什么我在 null 类型上获得访问数组偏移值?

问题描述

我正在尝试从数据库中获取用户详细信息并将其与发布的值进行比较。现在我得到Trying to access array offset on value of type null in。列名user_number存在于数据库中。这是我下面的代码.. 谢谢!!!

     <?php
     mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

     error_reporting(E_ALL | E_WARNING | E_NOTICE);

     ini_set('display_errors', TRUE);

      if (session_status() == PHP_SESSION_NONE) {
  session_start();

    }
     if(!isset($_SESSION['login']))
     {
     echo ("<script>location.href='../clogin/'</script>");
     die();
     }

     if (isset($_POST['submit'])) 
      {
      

        include_once('db.php');
       //get post details from user
             
        $UserNumber = $_POST['uNumber'];

        $sql = "SELECT * FROM customer WHERE user_number=?";   
        $stmt = $connection->prepare($sql); 
        $stmt->bind_param('i', $UserNumber);
        $stmt->execute();
        $result = $stmt->get_result();
        $count =  $result->num_rows;
      if($count == 1)
       { 
   
       while($row = $result->fetch_assoc());

         {


         $db_Uno = $row['user_number'];



           if($userNumber !== $db_Uno) 
           {


             
  echo'<script>swal.fire("FAILED!!", "<strong>No Customer with the user number you entered.</strong><hr><br/><i> Check well and try Again.</i>", "error");window.setTimeout(function(){
   window.location.href = "home.php";
   }, 2000);</script>'; 

             exit();
             }

              else
              {
               }


                 }//while loop
          
                  } //end of if rslt     


                    }// end submit for transfer post        
          
                      ?>           

很抱歉问这样一个新手问题。我试图修复它几个小时。还是同样的错误。

标签: phpmysqli

解决方案


推荐阅读