What potential compatibility issues can arise when using an older PHP version script on a server with a newer PHP version installed?

When using an older PHP version script on a server with a newer PHP version installed, compatibility issues can arise due to deprecated functions, changes in syntax, or removed features. To solve this issue, you can update the script to use modern PHP syntax and functions that are compatible with the newer PHP version.

// Example of updating deprecated function mysql_connect to mysqli_connect
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

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

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

echo "Connected successfully";

// Close connection
mysqli_close($conn);