Probably your $query is equal false because something went wrong, try mysql_error() to see whats wrong.
And 2 small advices:
would be better to use PDO od mysqli as mysql_* functions are deprecated.
use at least mysql_real_escape_string() to escape the value before putting it into SQL string