if you don't iterate through all results you get "server has gone away" error message ...
to resolve this, in php 5.2 it is enough to use
<?php
while ($mysqli->next_result());
?>
to drop unwanted results, but in php 5.3 using only this throws
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
so it should be replaced with
<?php
while ($mysqli->more_results() && $mysqli->next_result());
?>
I also tried but failed:
<?php
while ($mysqli->more_results())
$mysqli->next_result();
if ($mysqli->more_results())
while ($mysqli->next_result());
?>