usually I do it like this:
config.php
<?php
$db_user = "me";
$db_passwd = "me";
$db_name = "me";
$db_host = "me";
?>
functions.php
<?php
function connect_db() {
global $db_user, $db_passwd, $db_name, $db_host;
$con = mysql_connect($db_host,$db_user,$db_passwd);
if (!$con)
{
die(mysql_error());
}
mysql_select_db($db_name, $con);
}
?>
main.php
<?
include_once("./config.php");
session_start();
connect_db();
?>
also, put config.php into a separate directory and put a .htaccess file there to restrict access.