Covid-19 Coronavirus Live stats and updates

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.


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.


// your code goes here

Functions used