What are the potential pitfalls of transitioning from PHP5 to PHP7 when working with MySQL?

One potential pitfall when transitioning from PHP5 to PHP7 when working with MySQL is the deprecation of the mysql extension in PHP7, which may cause compatibility issues with existing code that relies on this extension. To solve this issue, it is recommended to switch to either the mysqli or PDO extension for interacting with MySQL databases in PHP7.

// Using mysqli extension to connect to MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

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

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