What potential issues can arise when using outdated MySQL functions in PHP code?

Using outdated MySQL functions in PHP code can lead to security vulnerabilities and compatibility issues with newer versions of MySQL. To solve this problem, it is recommended to switch to MySQLi or PDO extensions, which offer more secure and flexible ways to interact with MySQL databases.

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

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

// Perform a query using prepared statement
$stmt = $mysqli->prepare("SELECT * FROM table WHERE id = ?");
$stmt->bind_param("i", $id);
$id = 1;
$stmt->execute();
$result = $stmt->get_result();

// Fetch data
while ($row = $result->fetch_assoc()) {
    echo $row['column_name'];
}

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