Not sure... not much more I can tell you except to double check your username, password, host, and database. Are you saying that if you add:
mysql_connect($host,$username,$pass);
mysql_select_db($db_name);
To your existing code, it will connect? Seems strange -- it should work. Sorry I don't have much more insight to give you, since I don't know much about your installation.