put echo mysql_error(); right under the line $query = ...