Please read the documentation:
PHP: mysql_query - Manual[
^], and you will clearly see that when the query statement fails the call returns the boolean value FALSE. Do not assume that your API calls always do what you think; check the return values first.