-2

I am trying to select the table, but it show

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in

My code:

<?php
require 'database/db.php';
$fetch = $mysqli->query("SELECT * FROM buyhistory WHERE email = xxx@hotmail.com ORDER BY user_id DESC ");
while($row = mysqli_fetch_array($fetch))
{
echo "<tr>";
echo "<td>" . $row['purchasedate'] . "</td>";
echo "<td>" . $row['buyitem'] . "</td>";
echo "<td>" . $row['enddate'] . "</td>";
echo "</tr>";
}
?>

How to fix it?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • how to fix it? thanks – Alexandro Setiawan Jun 06 '15 at 10:27
  • By fixing whatever's wrong with your SQL query. You might start by enclosing string values in quotes. It's also a good idea to actually check for errors after executing a SQL query, since you're obviously getting an error and ignoring it here. – David Jun 06 '15 at 10:29

1 Answers1

0

should be email='xxx@hotmail.com'

$fetch = $mysqli->query("SELECT * FROM buyhistory WHERE email = 'xxx@hotmail.com' ORDER BY user_id DESC");
Manish Prajapati
  • 1,583
  • 2
  • 13
  • 21