AnsweredAssumed Answered

Sugarcrm 6.5: MySQL error 2014: Commands out of sync; you can't run this command now

Question asked by EL HADJI DEM on Apr 20, 2017
Latest reply on Apr 24, 2017 by EL HADJI DEM

Hello, I have a loop and I call the stored procedure  but I got this error: 

 

 MySQL error 2014: Commands out of sync; you can't run this command now

 

Here my code: 

global $db;

$sql = "SELECT id
FROM table1
WHERE status = 'Inprogress' ";

// Execute Query
$result = $db->query($sql);
if ($result){
   while ($row = $db->fetchByAssoc($result)) {
   / / Get the study id
   $visitId = $row['id'];
   $querymatch = "CALL mycustom('".$db->quote($contactId)."','".$db->quote($visitId)."')";
   $resultmatch = $db->query($querymatch);
   if ($onerow = $db->fetchByAssoc($resultmatch)){
      if (!empty($onerow['comment']) and strlen($onerow['comment'])!=0) {
         $insertQuery = "INSERT INTO table3
                                    (visit_id, contact_id)
                                    VALUES ('".$db->quote($visitId)."','".$db->quote($contactId)."')";
         // Verify success query
         $resultQuery = $db->query($insertQuery);
         if ($db->query($insertQuery)) {
            $i++;
            }
         }
      }
   }

}

Outcomes