php - Mysqli prepared statements Commands out of sync error
Get the solution ↓↓↓I'm having a little problem with some MySQLi prepared statements, which are throwing me the "Commands out of sync error", which is quite annoying. I've read on this forum about using
$stmt->free_result();
$stmt->close();
or
$db->next_result();
but no one of them has worked for me, this is what i've tried so far. Those are 3 functions which are sending database's results to others, to finally send a mail
function getTable($id) {
global $src;
$s="SELECT TEMA FROM lp_tavolo WHERE ID=?";
$q=$src->prepare($s) or die ($src->error);
$q->bind_param('s',$id);
$q->execute();
$q->store_result();
$q->bind_result($t);
while($q->fetch()) {
$q->close();
$src->next_result();
return $t;
}
}
function getID($m) {
global $src;
$s="SELECT ID FROM lp_partecipante WHERE EMAIL=?";
$q=$src->prepare($s) or die ($src->error);
$q->bind_param('s',$m);
$q->execute();
$q->store_result();
$q->bind_result($id);
while($q->fetch()) {
$q->close();
$src->next_result();
return $id;
}
}
function getExternalID($m) {
global $src;
$s="SELECT ID_TAVOLO FROM lp_partecipante WHERE EMAIL=?";
$q=$src->prepare($s) or die ($src->error);
$q->bind_param('s',$m);
$q->execute();
$q->store_result();
$q->bind_result($id);
while($q->fetch()) {
$q->close();
$src->next_result();
return $id;
}
}
function sendCredentials($name,$mail,$code) {
$table=getTable(getExternalID($mail));
}
The problem is that when i call thegetTable
function on agetExternalID
function result, all I get is an "out of sync error". What should I do?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: ftp_put(): can't open that file: no such file or directory
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.