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

2016 October 12 at 11:38 am Leave a comment

Kalau kita execute store procedure Mysql dalam pemograman PHP. Kemudian kita melanjutkan query selanjutnya maka kita akan mendapatkan error “Commands out of sync; you can’t run this command now“.

Berikut solusi yang didapat dari: Kita harus menyisipkan command yang memanggil custom function ‘clearStoredResults($sConn);‘  untuk membersihkan hasil query sebelumnya sebelum melanjutkan execute query berikutnya.

$sConn = mysqli_connect($servdb, $usrdb, $usrdbpasswd);
        echo "{msg:'Connection Error'}";
$db = mysqli_select_db ($sConn,$dbname);
$sql = "Call userlogin ('{$user}')";
$res=$sConn->query ($sql);
while($result = $res->fetch_array(MYSQLI_ASSOC)) {
        echo "Jumla baris=".$res->num_rows;
        echo    "<br>";
        echo    "<br>".$sql = "Update mtuser SET last_login=Now() Where iduser={$result['iduser']}";
        echo "<br>".mysqli_error($sConn);

function clearStoredResults($mysqli_link){
      if($l_result = $mysqli_link->store_result()){


Entry filed under: MYSQL, PHP, RELIGI. Tags: .

Script Auto Backup Restore MYSQL Dua Server dengan Banyak Database

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


%d bloggers like this: