You can try the following:
define("server","localhost");//The name of the server you are working with
define("db_user","myname");//The username that you've set to your DB
define("db_pass","mypassword");//The password that you've set to your DB
define("db_name","mydb");//Your database name.
$connect= mysql_connect(server,db_user,db_pass);//This establishes a connection with MySQL server
$db_select=mysql_select_db(db_name,$connect);//This selects the database to start working with it.
Once your code is finished you can print:
mysql_close($connect);//This will close the connection thatyou've initiated before
I hope that this will help you.