After the code connects to MySQL and selects the database, you can run SQL queries and perform other operations. For example, the following PHP code runs a SQL query that extracts the last names from the employees table, and stores the result in the $result variable:

Here you can create your own username and password also or you can choose given username and password for connecting PHP with Database.

The following program shows how to establish connection between PHP page with Database.

I am using the given username and password for your convenience. Ok, Lets go to the program.

<?php/* Connect to Database */

$host = “localhost”;// This is host name$user = “root”; // This is username$pass = “”; // This is password( No password is given)$connect=mysql_connect($host, $user, $pass);// gives connection between php and databseif($connect) { echo “Successfully connected to database”;// for our confirmation}?>