I was developing my own CMS and I was having problem with attaching the database' sql file. I thought mysqli_multi_query got bugs where it crashes my MySQL server. I tried to report the bug but it showed that it has duplicate bug reports of other developers. To my surprise, mysqli_multi_query needs to bother with result even if there's none.
I finally got it working when I copied the sample and removed somethings. Here is what it looked liked
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "CREATE TABLE....;...;... blah blah blah;...";
if (mysqli_multi_query($link, $query)) {
do {
if ($result = mysqli_store_result($link)) {
mysqli_free_result($result);
}
if (mysqli_more_results($link)) {
}
} while (mysqli_next_result($link));
}
mysqli_close($link);
?>
bottom-line: I think mysql_multi_query should only be used for attaching a database. it's hard to handle results from 'SELECT' statements inside a single while loop.