First, you will need to make a PHP script with this code
Please modify it to fit your settings
Code:
<?php
#Modify this with your info
$sql_localhost='localhost';
$sql_user_name='root';
$sql_user_pass='';
$sql_data_base='test_db';
#Do not edit this unless you know what you are doing#
$sql_c=mysql_connect($sql_localhost,$sql_user_name,$sql_user_pass);
if(!$sql_c) die('Could not Connect:'.$mysql_error());
$sql_seldb=mysql_select_db($sql_data_base);
if(!sql_seldb=mysql_select_db) die('Could not connect to database:'.mysql_error());
?>
Name that file above anything you want
(EXAMPLE : connect.php)
Now you can simply connect to your database in any php script by just having this code on the php script
Code:
include('connect.php');
NOTE : If you have a file which you create a function, make sure you put this inside the function (EXAMPLE)
Code:
<?php
include('connect.php');
function echorandom(){
include('connect.php');
}
?>