Sunfighter: Read the error message.
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
When PHP does a SELECT query, if it succeeds (even if the query returns no records), the result will be a record resource, not a boolean value.
If it fails
(with an error!) then the result will be the boolean
And so that error message is really saying "Hey, the query failed, so there is no actual result here and so there is nothing for mysqli_fetch_array
to work on."
As Fou-Lu said: He isn't doing any error handlng.
He should have coded something like
$result = $con->query("SELECT title, body AND category_id FROM posts ORDER BY DESC"
) or die( "ERROR IN QUERY: " . $con->error() );
(Notice that I used the more modern way of using mysqli, not the procedural style. And I don't even use PHP. <grin/>)
The point being that when the query fails and returns false
then the or die...
is triggered. So if you indeed reach the next line after that, then $result will be usable.