What are the consequences of using deprecated MySQL functions in PHP scripts?

Using deprecated MySQL functions in PHP scripts can lead to security vulnerabilities and compatibility issues with newer versions of MySQL. To solve this problem, you should switch to using MySQLi or PDO extensions, which offer improved security features and better support for modern MySQL databases.

// Connect to MySQL using MySQLi extension
$mysqli = new mysqli("localhost", "username", "password", "dbname");

if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Perform a query using prepared statements
$stmt = $mysqli->prepare("SELECT * FROM table WHERE column = ?");
$stmt->bind_param("s", $value);
$value = "example";
$stmt->execute();
$result = $stmt->get_result();

// Fetch results
while ($row = $result->fetch_assoc()) {
    // Process results
}

// Close connection
$stmt->close();
$mysqli->close();