Why don't you put the whole DBconnect into a function?
Part of the common.php I include in my files:
<?
/**
MySQL details
Login Name, Password, Database, Table Name, Etc.
**/
$dbHost = "localhost";
$dbUser = "root";
$dbPass = "pass";
$dbName = "databasename";
$table = "tablename";
$link = "";
/** now onto the business **/
function openLink() {
global $dbHost;
global $dbUser;
global $dbPass;
global $dbName;
global $link;
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
if (!$link) {
print "<b>Error:</b> Could not connect to database<br>";
return false;
}
if (!@mysql_select_db($dbName)) {
print "<b>Error:</b> Could not find database<br>";
return false;
}
} // close function
?>