我一直试图让这个 php 函数工作一段时间,但没有成功。由于某种原因,每次运行时,我的 mysql 中都会出现“命令不同步,您现在无法运行此命令”错误。我正在使用与我在所有其他 php 项目中所做的相同的技术,即调用 mysqli->next_result 以便我可以避免该错误。但是,当我在这里调用它时,它似乎没有任何效果。
if($questionType == 5){
global $To;
$to="znielsen@gbpi.net";
$subject = "txtoutage session completed";
$message ="Session completed by: ".$number." \n on: ".date("Y-m-d H:i:s")." \n";
if($sid = $mysqli->query("CALL GetSessionFromPhoneNumProc('$number')")){
$sids = $sid->fetch_assoc();
$sid->free();
$sids = $sids['sid'];
$mysqli->close();
$res->free();
if($res = $mysqli->query("CALL GetAnswersFromSession('$sids')")){
while($row = $res->fetch_assoc()){
$mysqli->next_result();
$qid = $row['Question_ID'];
$question = $mysqli->query("SELECT Question_Text FROM questions WHERE Question_ID = '$qid'");
$question = $question->fetch_assoc();
$question = $question['Question_Text'];
if($row['Answer_Text'] == null){
$displayText = $row['Answer_Body'];
}
else{
$displayText = $row['Answer_Text'];
}
$message = $message.$question.": ".$displayText." \n";
}
}
else{
$log->logError("mysql error sess: (" . $mysqli->errno . ") " . $mysqli->error);
}
}
else{
$log->logError("mysql error answers: (" . $mysqli->errno . ") " . $mysqli->error);
}
$from = "txtoutage@gbpi.net";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
}