What are the potential issues when calling multiple MySQL procedures using the MySQLi API in PHP?

When calling multiple MySQL procedures using the MySQLi API in PHP, one potential issue is that the connection may be closed after executing each procedure, causing subsequent calls to fail. To solve this, you can use the `multi_query` method to execute multiple queries in a single call, ensuring that the connection remains open throughout.

<?php
$mysqli = new mysqli("localhost", "username", "password", "database");

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

$query = "CALL procedure1(); CALL procedure2(); CALL procedure3();";
if ($mysqli->multi_query($query)) {
    do {
        if ($result = $mysqli->store_result()) {
            $result->free();
        }
    } while ($mysqli->more_results() && $mysqli->next_result());
} else {
    echo "Error: " . $mysqli->error;
}

$mysqli->close();
?>