<?php
mysql_connect("db_host","db_user","db_pass");
mysql_select_db("db_name");
?>

Where db_host, db_user, db_pass and db_name is the host, username, password and name for your database respectively.

General practice is to save the code in a separate file in the ‘includes’ folder and including it on the page where you need it.

<?php include("database.php") ?>