What are the drawbacks of using deprecated functions like mysql_ in PHP scripts?

Using deprecated functions like `mysql_` in PHP scripts can lead to security vulnerabilities and compatibility issues with newer versions of PHP. It is recommended to switch to the improved MySQLi or PDO extensions for better security, performance, and long-term support.

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

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

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

// Perform SQL queries using prepared statements
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?");
$stmt->bind_param("i", $id);
$id = 1;
$stmt->execute();
$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {
    echo "Name: " . $row["name"] . "<br>";
}

$stmt->close();
$conn->close();