I use this in my files:
include("stuff.inc");
$connection = mysql_connect($host,$user,$password)
or die ("Could not connect to the database");
$db = mysql_select_db($database, $connection)
or die ("Could not select the database");
and the include looks like:
<?php
$host="host name";
$user="user name";
$password="password";
$database="database name";
?>
obviously I've changed the details but thats the gist of it.