I'm getting the "Commands out of sync" error which seems to be typically resolved by freeing the result of a previous query, but I'm not sure how to apply this to my scenario.
I've attempted to free results from other queries in various locations of the php script but the error does not resolve. Examples I find have a query formatted like $result = $mysqli->query() then free the $result. I'm not using this style of result, but if I should, I am open to modifying my approach.
//Check if active checklist table exists and if not create it
$activeExist = $mysqli->query("CALL TEST('active')");
while ($row = $activeExist->fetch_row()) {
echo $row[0];
error_log($row[0]."\n\n", 3, "/var/tmp/my-errors.log");
if ($row[0] == "2") {
//$activeExist->free();
$sql = "CREATE TABLE IF NOT EXISTS active (
id varchar(10) NOT NULL PRIMARY KEY,
title varchar(100)) SELECT '$activeID' AS 'id', '$realname' AS 'title';";
$mysqli->query($sql);
error_log("Active then statement from dbTableGen ".$sql."\n\n", 3, "/var/tmp/my-errors.log");
error_log("Active (" . $mysqli->errno . ") " . $mysqli->error ."\n\n", 3, "/var/tmp/my-errors.log");
//$mysqli->query("INSERT INTO active VALUES ('$activeID', '$realname')");
}
else {
error_log("Active else statement from dbTableGen"."\n\n", 3, "/var/tmp/my-errors.log");
$mysqli->query("INSERT INTO active VALUES ('$activeID', '$realname')");
}
}
}
//mysqli_free_result();
mysqli_close($mysqli);
Expected result: creation of a table called "active" and inserting of values IF the table does not already exist OR just inserting the values IF the table already exists.
Actual result: Commands out of sync; you can't run this command now