Sai Sai - 3 years ago 84
PHP Question

i can't edit my user data

i try to edit/update my data form but when i click on"edit" button it doesn't change anything and i don't know what has exactly happened, the output said


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


coding

<?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");?>

Answer Source

your query is the main problem

$query = "select*from requestform";

change to this

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download