How do you mean..?
Just make a php-file called database.php or something like that. In that file you put:
$hostname = "localhost";
$username = "user";
$password = "pass";
$dbname = "database";
$connection=mysql_connect($hostname, $username, $password);
mysql_select_db($dbname) or die("Sorry, the database is down at the moment.");
Then you include that file in the one where you want the connection:
include("database.php");
Put it somewhere in the beginning of your script and don't put it in a if-condition or another loop, else it will only be usuable in between the { } brackets.
At the end of your script you put:
mysql_close($connection);
That's all..