This a FAQ (Frequentyl Asked Question) which has been asked and answered multiple times and can be also solved by reading the documentation:
Return Values
Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.
You have to check the return value of
mysqli_query()
as shown in the examples at the above link before passing it to other functions like
mysqli_num_rows()
.
Upon failures report the error message to know what went wrong. Usual errors sources are invalid SQL commands and the message provided by
mysqli_error($conn)
will tell you what was wrong. Because I don't know about your database, I can only guess. Here it might be a typo in one of the column names or the table name.