I want to truncate multiple tables and trying the following code to achieve that.
$tables = array("students","fees","test","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
for($i=0;$i<15; $i++){
$del_all = "TRUNCATE TABLE ".$tables[$i];
$res = $conn->query($del_all); //line no. 221
$res->store_result();
$res->free_result();
$res->close();
}
echo "<div class='w3-panel w3-green w3-display-container' style='width:40%;'>
<span onclick='this.parentElement.style.display='none''
class='w3-button w3-large w3-display-topright'>×</span>
<p>Records Cleared!</p>
</div>";
After executing, it is giving
error: Commands out of sync; you can't run this command now' in C:\wamp\www\classlearn\delete.php on line 221`.
I have applied $res->store_result();
, $res->free_result();
and $res->close();
then, also, I am getting this error. What is the problem?
My question is not a duplicate. I have implemented store_result()
, free_result()
and close()
which the previous question asker didn't implemented.