i generally use this file
<?//file dbconn.php
$vusername = "****"; //your username for you local system
$pwd ="****"; //password to accecss mySQL
$host = "localhost"; //host is localhost - even for most web hosts
$dbname = "test"; //db name to be accessed
//connect to db
if (!($conn=mysql_connect($host, $vusername, $pwd))) {
printf("error connecting to DB by user = $vusername and pwd=$pwd");
exit;
}
$db=mysql_select_db($dbname,$conn) or die("Unable to connect to database");
?>
I use this page by placing the following in each page that needs db access
require("dbconn.php");
//create the sql statment
$sql="select * from table [blah blah blah]";
$result=mysql_query($sql,$conn) or die ("Can't connect because ".mysql_error());
hth