Loading…

How to make database connection in PHP?

Example

                                        

$servername = "your hostname";
$username = "your database username";
$password = "your database password";


// Create connection


$conn = new mysqli($servername, $username, $password);


// Check connection


if ($conn->connect_error) {
die("Not Connected: " . $conn->connect_error);
}
echo "Connected";

Suggest An Answer

No suggestions avaliable!

Latest post from PHP interview questions

Ask Question