We will tell you how to connect the database in PHP. In any PHP file for insert/Delete/update/fetch data from Mysql database. we have to create a connection with the Mysql database. This connection will be the type of the database is Mysql. Follow the bellow Code to creating a connection with the Mysql database.

Method 1:

mysql_connect('localhost', 'root', 'pass');

localhost : is the Host of the Server

root ; is the username of the Database

pass : is the password of the Database

database : is the name of the Mysql database


Method 2:

         $dbhost = 'localhost:3306';
         $dbuser = 'root';
         $dbpass = 'pass';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         echo 'Connected successfully';

How to Delete Data From Mysql Database

Read on Facebook