There is a permanent loop in the do {} sentence. What are you trying to do with it?
You should either remove it or place a real condition:
/* execute multi query */
if ($mysqli->multi_query($query))
{
$n = 0;
while(CERTAIN CONDITION)
{
/* store first result set */
if ($result = $mysqli->store_result())
{
$i = 1;
$p = 1;
while ($row = $result->fetch_row())
{
print_r($row);
$n++;
}
}
}
}
/* close connection */
$mysqli->close();