Home >Backend Development >PHP Tutorial >Why Am I Getting a \'mysqli_next_result(): There is no next result set\' Error with mysqli_multi_query?
Strict Standards: mysqli_next_result() error with mysqli_multi_query
Many developers encounter a strict Standards error when using mysqli_multi_query. This error message reads "mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method."
Root Cause
The error arises when mysqli_multi_query is used without checking whether there are subsequent result sets. By default, mysqli_next_result proceeds to the next result set, even if none exists. To avoid the error, the function mysqli_more_results should be invoked beforehand to ascertain the presence of any additional result sets.
Solution
To resolve the problem, use the following code:
if (mysqli_multi_query($db, $querystring)) { do { if ($result = mysqli_store_result($db)) { // ... } } while (mysqli_more_results($db) && mysqli_next_result($db)); }
This ensures that mysqli_next_result is only executed if there is a subsequent result set.
Additional Notes
The above is the detailed content of Why Am I Getting a 'mysqli_next_result(): There is no next result set' Error with mysqli_multi_query?. For more information, please follow other related articles on the PHP Chinese website!