php - Commands out of sync; you can't run this command now: multiple queries, not simultaneous -


i'm making php/mysql(i) website application, , getting dreaded error, "commands out of sync; can't run command now".

i have connection database.

(p.s. - different other questions similar titles -- have gone through them all. want open first query, close first query, open second query. not want execute multiple statements @ once, or open multiple result-sets simultaneously)

here doing:

<?php $sql = 'call spselectproductandvendor(1, 1)';  $rs = $mysqli->query($sql); echo($mysqli->error); if ($rs->num_rows > 0) {     while ($row=$rs->fetch_assoc()) {         echo '<h1 class="page-header">' . $row["productname"] . '<small> pertaining vendor: ' . $row["vendorname"] . '</small></h1>';     }    }    $rs->close(); ?> 

html/css

<?php $sql = 'call spselectrecentdocumentscores();'; $rs = $mysqli->query($sql); echo($mysqli->error); if ($rs->num_rows > 0) {     while ($row=$rs->fetch_assoc()) {         if($row["totalwarnings"]>50) { echo '<tr class="danger">'; } else { echo '<tr class="active">'; } ?> <td><a href="documentdetail.php?documentid=<?php echo $row["documentid"]; ?>" style="color:#000000"><?php echo $row["documentid"]; ?></a></td> <td>etc...</td> </tr> <?php     } } ?> 

why error occur upon second call?

$rs = $mysqli->query($sql); 

the first 1 works fine. second not. closing first $rs. missing?

figured out.. need add $conn->next_result(); after first resultset closed:

$rs->close(); $mysqli->next_result(); 

then second $rs may safely opened.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -