I have a script that uses MySQLi for it's multi_query capabilities. For some reason, when I run my second query I get an error that says:
Commands out of sync; you can't run this command now
Here is the code:
$partResult = mysqli_query($link, $partQuery);
$queryId = mysqli_insert_id($link);
$_SESSION['queryId'] = $queryId;
//Insert Search Results into Result table
$resultQuery = "";
$_SESSION['partTotal'] = 0;
while($partData = mysqli_fetch_array($partResult))
{
$_SESSION['partTotal']++;
//Here we will insert the result into the database.
$resultQuery .= "INSERT INTO `searchResults` (`queryId`,`partId`,`miles`) VALUES ('$queryId','$partData[id]','$milesAway');";
}
mysqli_free_result($partResult);
$searchResult = mysqli_multi_query($link, $resultQuery) or die(mysqli_error($link));
The last line of code there returns the error. Everything I find from searching just says to make sure I use free_result but I do use that right before I execute my last query.