How to Connect the Database in PHP
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: <?php mysql_connect('localhost', 'root', 'pass'); mysql_select_db('databse'); ?> 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: <?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close(...