if (!(mysql_num_rows($query2))) echo mysql_error();

metti questo al posto del tuo if / echo