the problem is that mysql_query() executes the query but it alone does not return what you are looking for. so even if the query itself returns 1 or more, $count login itself does not equal 1. so let's go to the next line:
this is where it all fails. you need the function mysql_num_rows(). or in other words replace the existing condition with
and that is of course your logic is correct. what i prefer myself is to store the query in a variable outside the functions and echo out the variable and test the query alone.
on a side note-mysql_close()-there is no point in using it. get rid of it.