The most Popular databases used with the php is MySQL .
You can Connect with Php MySQL using mysql_connect() function and mysql_select_db() function to select the database .
Rules :
<?php
$connection = mysql_connect(‘localhost’, ‘mysql_username’, ‘mysql_password’);
if (!$connection) {
die(‘You are not connected to database : ‘ . mysql_error());
}
// make foo the current db
$select_db = mysql_select_db(‘my_database’, $connection);
if (!$select_db) {
die (‘Database is not selected : ‘ . mysql_error());
}
?>
Here ,
mysql_connect() function establish connection with database .
mysql_select_db() is used the select the current database .
mysql_error() returns the connection errors .