Warning: mysql_ finctions are deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.
You are not checking if the mysql_query was successful or not. If the query was unsuccessful mysql_query returns false. Refer to mysql_query Manual
Try
$result=mysql_query($sql);
if ($result==false)
{
die(mysql_error());
}
$count=mysql_num_rows($result);