Lab #5

Establishing a Connection, Working With Database

1. Write a PHP script to connect the MySql server from your web application

<?php
$servername = "localhost";
$username = "username";
$password = "password";

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

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

Try yourself to see the output

Happy Coding :)