我无法编辑我的用户数据
i can't edit my user data
我尝试 edit/update 我的数据表单但是当我点击 "edit" 按钮时它没有任何改变而且我不知道到底发生了什么,输出说
Fatal error: Uncaught Error: Call to a member function query() on null
in C:\xampp\htdocs\Admin\requestform5.php:24 Stack trace: #0 {main}
thrown in C:\xampp\htdocs\Admin\requestform5.php on line 24
编码
<?php
include "errorReporting.php";
include "conn.php";
$conn = connect();
$db = connectdb();
$wardID = $_REQUEST["wardID"];
$RequestName = $_REQUEST["RequestName"];
$Department =$_REQUEST["Department"];
$Position =$_REQUEST["Position"];
$Date=$_REQUEST["Date"];
$TypeOfRequest=$_REQUEST["TypeOfRequest"];
$PleaseSpecify=$_REQUEST["PleaseSpecify"];
$DateRequire= $_REQUEST["DateRequire"];
$DateReturn= $_REQUEST["DateReturn"];
mysqli_select_db ($conn,"admin") or die ($conn->error ."\n");
$query = "select*from requestform";
$result= $conn->query($query) or die ($conn->error."\n");
$row_result =mysqli_fetch_assoc($result);
mysqli_select_db ($conn,"admin") or die ($conn->error."\n");
$mysqli->query( "UPDATE requestform SET RequestName='$RequestName',Department='$Department',Position='$Position',Date='$Date',TypeOfRequest='$TypeOfRequest',PleaseSpecify='$PleaseSpecify',DateRequire='$DateRequire',DateReturn='$DateReturn' where wardID='$wardID'");
$mysqli->affected_rows or die ($conn->error()."\n");
header("Location:requestform3.php");?>
你的查询是主要问题
$query = "select*from requestform";
改成这个
mysqli_select_db ($conn,"admin") or die ($conn->error ."\n");
$query = "select * from requestform";
$result= $conn->query($query) or die ($conn->error."\n");
$row_result =mysqli_fetch_assoc($result);
$conn->query( "UPDATE requestform SET RequestName='$RequestName',Department='$Department',Position='$Position',Date='$Date',TypeOfRequest='$TypeOfRequest',PleaseSpecify='$PleaseSpecify',DateRequire='$DateRequire',DateReturn='$DateReturn' where wardID='$wardID'");
$conn->affected_rows or die ($conn->error()."\n");
问题出在第24行
$mysqli->query("UPDATE requestform SET RequestName='$RequestName',Department='$Department',Position='$Position',Date='$Date',TypeOfRequest='$TypeOfRequest',PleaseSpecify='$PleaseSpecify',DateRequire='$DateRequire',DateReturn='$DateReturn' where wardID='$wardID'");
$mysqli->affected_rows 否则死掉($conn->error()."\n");
这个 $mysqli 是从哪里来的?这是一个对象吗?我在任何地方都看不到这个物体。你有 $conn 对象。
把$mysqli->query改成$conn->query
我尝试 edit/update 我的数据表单但是当我点击 "edit" 按钮时它没有任何改变而且我不知道到底发生了什么,输出说
Fatal error: Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\Admin\requestform5.php:24 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Admin\requestform5.php on line 24
编码
<?php
include "errorReporting.php";
include "conn.php";
$conn = connect();
$db = connectdb();
$wardID = $_REQUEST["wardID"];
$RequestName = $_REQUEST["RequestName"];
$Department =$_REQUEST["Department"];
$Position =$_REQUEST["Position"];
$Date=$_REQUEST["Date"];
$TypeOfRequest=$_REQUEST["TypeOfRequest"];
$PleaseSpecify=$_REQUEST["PleaseSpecify"];
$DateRequire= $_REQUEST["DateRequire"];
$DateReturn= $_REQUEST["DateReturn"];
mysqli_select_db ($conn,"admin") or die ($conn->error ."\n");
$query = "select*from requestform";
$result= $conn->query($query) or die ($conn->error."\n");
$row_result =mysqli_fetch_assoc($result);
mysqli_select_db ($conn,"admin") or die ($conn->error."\n");
$mysqli->query( "UPDATE requestform SET RequestName='$RequestName',Department='$Department',Position='$Position',Date='$Date',TypeOfRequest='$TypeOfRequest',PleaseSpecify='$PleaseSpecify',DateRequire='$DateRequire',DateReturn='$DateReturn' where wardID='$wardID'");
$mysqli->affected_rows or die ($conn->error()."\n");
header("Location:requestform3.php");?>
你的查询是主要问题
$query = "select*from requestform";
改成这个
mysqli_select_db ($conn,"admin") or die ($conn->error ."\n");
$query = "select * from requestform";
$result= $conn->query($query) or die ($conn->error."\n");
$row_result =mysqli_fetch_assoc($result);
$conn->query( "UPDATE requestform SET RequestName='$RequestName',Department='$Department',Position='$Position',Date='$Date',TypeOfRequest='$TypeOfRequest',PleaseSpecify='$PleaseSpecify',DateRequire='$DateRequire',DateReturn='$DateReturn' where wardID='$wardID'");
$conn->affected_rows or die ($conn->error()."\n");
问题出在第24行
$mysqli->query("UPDATE requestform SET RequestName='$RequestName',Department='$Department',Position='$Position',Date='$Date',TypeOfRequest='$TypeOfRequest',PleaseSpecify='$PleaseSpecify',DateRequire='$DateRequire',DateReturn='$DateReturn' where wardID='$wardID'"); $mysqli->affected_rows 否则死掉($conn->error()."\n");
这个 $mysqli 是从哪里来的?这是一个对象吗?我在任何地方都看不到这个物体。你有 $conn 对象。
把$mysqli->query改成$conn->query