Well first of all, use this:
$connection = mysql_connect("localhost", "uname", "pass");
mysql_select_db("database", $connection);
$query = "SELECT * FROM databaseTable";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
that should fix the problem