the thing i do is set all my username and password in a file and include it..
$dbhost = "localhost";
$dbuser = "username";
$dbpass = "password";
$dbname = "database";
$table = "tablename";
and then use the following statement to connect to it and select the database.
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die('not connected');
if(mysql_select_db($dbname,$connect));
else die ("not connected to db");