The Code:
$query = "SELECT * FROM tweets WHERE read=n";
$result = mysqli_query($mysqli,$query);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
echo $row["from_user"], $row["text"];
The above code gives me this:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /index.php on line 16
The below code does not:
$query = "SELECT * FROM tweets";
$result = mysqli_query($mysqli,$query);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
echo $row["from_user"], $row["text"];
The “read” field is ENUM(‘y’,’n’).
readis a reserved keyword in MySQL. As it’s the name of your column, add backticks surrounding the word in your WHERE clause and that should fix the issue: