Mysql Connection

<?php
	/* Your mysql server host name */
	$host = "localhost";
	
	/* Mysql database user name */
	$user = "root";
	
	/* Mysql database user password */
	$password = "yourpassword";
	
	/* Mysql database name */
	$database = "test";
	
	
	/* Open connection mysql server in mysqli procedural */
	$connect = mysqli_connect($host, $user, $password, $database);
	
	if(!$connect)
        	die("Failed to connect with database!");

    	echo "Database connected!";
	
	/* Close Connection */
	mysqli_close($connect);
	


	/* Open connection mysql server in mysqli object oriented */
	$connect = new mysqli($host, $user, $password, $database);
	if($connect->error)
    	    die("Failed to connect with database");
    
    	echo "Database connected!";

	/* Close connection */
    	$connect->close();
?> 


/* Output */
Connection Establish with database!


Connection Establish with database!
                                Copy Code