0

I Am trying to edit user details from a database. I have queried the database and stored the info in $row, but each time I try to echo the details I get the following error: Trying to access array offset on the value of type null in

C:\xampp\htdocs\merchant\admin\edituserhis.php

I seem not to know what I am doing wrong in the SQL statement, I have checked the Variable $id and its working well.

 <div class="quotes">

<?php        
$con = mysqli_connect("localhost","root","","merchant_db");

$id = $_REQUEST['username'];
$query = "SELECT * from user_trans where userid='".$id."'";
$result = mysqli_query($con, $query) or die ( mysqli_error());
$row = mysqli_fetch_assoc($result);

?>
<?php echo $row['userid']; ?>;

           <form name="form" method="post" action="userprofile.php"> 
<input type="hidden" name="new" value="1" />
<input name="id" type="hidden" value="<?php echo $row['userid'];?>" />

<p><input type="text" name="balance" placeholder="Enter Amount" required value="<?php echo $row['description'];?>" /></p>
<p><input name="submit" type="submit" value="Credit" /></p>
</form>


</div>
Basil
  • 23
  • 7
  • 1
    You have an error. [`mysqli_error()`](https://www.php.net/manual/en/mysqli.error.php) needs one argument. Please consider switching error mode on instead. [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman May 27 '20 at 18:37
  • can you please add your database structure's screen shot in your post. – mufazmi May 27 '20 at 18:48
  • When you load the page you have to check for $_REQUEST(). Without that being set your $row will have no value. – RST May 27 '20 at 18:55
  • @RST How do I check for $_REQUEST()? – Basil May 27 '20 at 19:24
  • @MUFAzmi I have added the database structure to my post – Basil May 27 '20 at 19:27
  • I meant $_REQUEST[], check if it is set, if it has a value. If you don't know what that means do a search on the internet for php how to check variables – RST May 27 '20 at 19:31
  • @RST I have checked $_REQUEST[] and it has a value – Basil May 28 '20 at 10:01
  • You need to adjust your code to perform the check on every page load. Share what the value is. Provide good information otherwise people will not be able/willing to help you. You put a link to a file on your own computer in your text (c://) how do you expect we access that? – RST May 28 '20 at 11:34
  • you have share a small number of code here, so we can't able to find the mistake into your code. – mufazmi May 30 '20 at 10:44

0 Answers0