How to connect mysql database in php?

In php, connect mysql database using mysqli_connect() method.

It takes four arguments.

ArgumentsDescription
HostnameName of the Host (Localhost)
UsernameName of the Database user (In xampp default username is root )
PasswordUser password
DatabaseName of the Database

Example

<?php
$con = mysqli_connect('localhost', 'root', '', 'myDB');
if(!$con) {
   die('Connection not established.');
}
?>

kabeer

Added  Jul 02, 06:19 pm

×
Google login
SignUp with Email
X