Published on August 12, 2024By DeveloperBreeze
PHP: How to Connect to a MySQL Database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
Comments
Please log in to leave a comment.