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.
Now it is obvious that in the line
$conn->query($sql)
you got a boolean answer (probably an error)...
As query can return something different from a result-set you must check its return value and act accordingly...