What are the implications of using outdated PHP versions on the security and functionality of code that relies on deprecated functions like mysql_real_escape_string()?

Using outdated PHP versions can pose significant security risks as deprecated functions like mysql_real_escape_string() are no longer supported and may be vulnerable to SQL injection attacks. To address this issue, it is recommended to update to the latest PHP version and use modern alternatives like prepared statements or mysqli_real_escape_string() to ensure secure data handling.

// Using mysqli_real_escape_string() to escape input data
$mysqli = new mysqli("localhost", "username", "password", "database");

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

// Escape input data using mysqli_real_escape_string()
$input_data = $mysqli->real_escape_string($input_data);

// Use the escaped input data in your SQL query
$query = "SELECT * FROM table WHERE column = '$input_data'";
$result = $mysqli->query($query);

// Process the result
if ($result->num_rows > 0) {
    // Output data
} else {
    echo "No results found";
}

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