How to Create MYSQL Database Connection File in PHP

Create MYSQL Database Connection File in PHPWhenever you are working on a project you might need to create a database connection and select a database.
Here i am going to show you a simple way to create your simple mysql database connection file in php.

define('HOST','localhost');
define('USER','root');
define('PASS','');
define('DATABASE','etallu');

mysql_connect(HOST,USER,PASS) or die("Database connection faild: " . mysql_error());

mysql_select_db(DATABASE) or die("Database selection faild: " . mysql_error());

Now save this as connection.php and include this file on top of every page of your PHP script.

include_once('connection.php');

// your code goes here

Functions used