What are common issues when connecting PHP to MySQL databases on a Debian Sarge server?

Common issues when connecting PHP to MySQL databases on a Debian Sarge server include incorrect database credentials, missing MySQL extension for PHP, and firewall restrictions blocking the connection. To solve these issues, ensure that the database credentials in your PHP code are correct, install the necessary MySQL extension for PHP, and check that the server's firewall allows connections to the MySQL database.

<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$database = "your_database";

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

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