php - 为什么我在 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
?>
很抱歉问这样一个新手问题。我试图修复它几个小时。还是同样的错误。
解决方案
推荐阅读
- python - tensorflow 音频识别错误“标题不匹配:预期 RIFF 但找到”
- xml - Golang xml unmarshal:如果我们在嵌套结构中使用 Xml 名称元素,则只有根元素会被解组
- unity3d - FileNotFoundException: Temp\gradleOut\build\outputs\bundle\release\gradleOut.aab 不存在
- c - 如果编译器要求程序中给出更多数量的输入,那么程序中是否有任何错误
- azure - 使用 Terraform 将托管身份访问权限分配给应用程序角色
- mysql - MySQL 意外关闭。(XAMPP)
- android - 如何在 android studio 中导入或打开 react-native 项目?
- python-3.x - python3奇怪的文件路径问题;代码本身没有错误;纯粹为了知识
- python - 如何在 Pandas 中从列转向行
- bash - 我想重新执行之前使用的第 n 个命令和最后一个名称以 m 开头的命令