What are the key reasons for the eventual phasing out of the mysql_ extension in PHP in favor of mysqli_?

The key reasons for phasing out the mysql_ extension in PHP in favor of mysqli_ are due to security vulnerabilities, lack of support for modern MySQL features, and better performance capabilities offered by mysqli_. To solve this issue, developers should migrate their codebase to use mysqli_ functions instead of mysql_ functions to ensure compatibility with newer PHP versions and maintain secure database operations.

// Connect to MySQL database using mysqli
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

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

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