You haven't done anything to verify your query.
The answer is simple, the query has failed. Standard check of
mysqli_error($con); will tell you the cause.
This is also not doable:
if (!mysqli_query($con,$sql)) . If the first one fails, that would trigger the same error as posted, if it was successful it will trigger an error on an incorrect argument datatype. You simply cannot query a query resultset.
header('HTTP/1.1 420 Enhance Your Calm');