Welcome to Techno Smarter QA, Question, Answer forum. Ask questions, receive answers, or help someone. Join Now
+2 votes

I am working with PHP and MYSQL database . I am getting an error mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\hp_gas\update.php on line 12 .

I am attaching my PHP code .  


$host = 'localhost';

$username = 'root';

$pass = '';

$db = 'tutorial';

$conn = new mysqli($host,$username,$pass,$db);


$result = mysqli_query($conn,"SELECT from added_date Where id=$id");


$issuedate = $res['i_date'];



HTML form code 

<!DOCTYPE html>







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

$id = $_POST['id'];

$issuedate = $_POST['issuedate'];

$result = mysqli_query($conn, "UPDATE added_date set i_date='$issuedate' WHERE id=$id");

echo "Updated";

} else{

echo "Sorry";



<form method="post" action="">

<label>Issue Date</label>

          <input type="date" name="issuedate" id="issuedate"  class="form-control" value="<?php echo $issuedate; ?>">


          <input type="hidden" name="id" value=<?php echo $_GET['id']; ?>>

          <input type="submit" name="submit">




I am updating data using PHP and MYSQL database but getting error like mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool is given. 

How can I fix this error in PHP? 

in PHP by (180 points) 1 2 7

3 Answers

+1 vote

I have checked your code. You are working for update operation in PHP with an MYSQL database. You have many issues in your code. As I can see, you are getting "mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in ". This happens when you did a mistake in your connection file or query. Your MySQL query looks good but the connection is not well. 

I am removing issues from your PHP code.  

$host = 'localhost';

$username = 'root';

$pass = ' ';

$db = 'tutorial';

$conn = mysqli_connect($host,$username,$pass,$db);

Kindly check these PHP lines and update your code.

You can learn from the tutorial - Update operation in PHP with  MYSQL database

by (7.2k points) 14 29 62
+1 vote

You are missing PHP mysqli_connect() function and syntax error in connection code. You have used new keyword with mysqli. First of understanding the error "mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given" This error shows that the variable values is not coming or something missing in your MYSQL query , connection variable . Make sure update these two lines - 

$pass = ' ';

and the next  line . 

$conn = mysqli_connect($host,$username,$pass,$db);

No need to use NEW keyword . 

Kindly check all syntaxes, functions, and query before the mysqli_fetch_array() function . 

by (9.1k points) 11 25 63
+1 vote

As you can see , I have answered above. One more line has an issue in your PHP code . 

You are missing asterisk * symbol in your PHP query. 

$result = mysqli_query($conn,"SELECT* FROM added_date WHERE id=$id");

by (7.2k points) 14 29 62