This question is asked almost every day. Just look at the "Related questions" list - and that's just a small sample.
As always, the answer is that you need to read the documentation:
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
Something has gone wrong with your query. You need to test whether the method returned
FALSE
before trying to read the results.
NB: The MySQL extension has been deprecated since 5.5, and was removed completely in 7.0; you need to use MySQLi or PDO instead.
PHP: Choosing an API - Manual[
^]