In your final query before the Access Denied part, you are referring to $Email and $password - neither of which are stated in the code you posted.
If you changed these to $uid and $pwd, you might get a better response.
Also, if there is a successful login - ie mysql_num_rows($result) gives a result of 1, then there is no place for this eventuality.
It might be a good idea to echo out your SQL query as well, at least you will be able to find out why the query didn't work.
If you had missed out a } you would have received a parse error though, not just an anomolous answer to your code.