0

I'm facing the following mysqli error

Commands out of sync; you can't run this command now

How can I solve the issue?

multiquery = '';
for(i = 0; i<count($varA); $i++)
{
    $multiquery .= " INSERT INTO tblA (columnA, columnB) VALUES ('$varA', '$varB');";
}
if(mysqli_multi_query($DBcon, $multiquery))
{
    $query = $DBcon-> query("Insert INTO tblB (columnC, columnD) VALUES ('$varC', '$varD')");
    if($query)
    {
        echo "OK";
    }
    else
    {
        echo "query error";
    }
}
else
{
    echo "multiquery error";
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Arun Karthick
  • 326
  • 2
  • 4
  • 16
  • It may be worth fixing the potential SQL injection vulnerabilities first. – halfer Nov 26 '18 at 09:00
  • Possible duplicate of [Why is mysqli giving a "Commands out of sync" error?](https://stackoverflow.com/questions/3632075/why-is-mysqli-giving-a-commands-out-of-sync-error) – halfer Nov 26 '18 at 09:01

0 Answers0