1$servername = "localhost";
2$username = "username";
3$password = "password";
4
5// Create connection
6$conn = new mysqli($servername, $username, $password);
7
8// Check connection
9if ($conn->connect_error) {
10 die("Connection failed: " . $conn->connect_error);
11}
12echo "Connected successfully";
13
14
15Simplified
16
17$conn = mysqli_connect('localhost', 'username', 'password');
18$database = mysqli_select_db($conn, 'database');
1<?php
2$servername = "localhost";
3$username = "username";
4$password = "password";
5
6// Create connection
7$conn = new mysqli($servername, $username, $password);
8
9// Check connection
10if ($conn->connect_error) {
11 die("Connection failed: " . $conn->connect_error);
12}
13echo "Connected successfully";
14?>