Jump to content

Error: Commands out of sync


GeXus

Recommended Posts

I receive the following error message "Error: Commands out of sync; you can't run this command nowQuery: CALL get_categories();" when using mysqli and stored procedures...  Any idea why I would get this?  The code is below... thanks a lot!!

 

 

<?
session_start();
error_reporting(E_ALL);
require_once('includes/config.php');
$db = mysql_connection();

        if(isset($_GET['cat_id'])){
       
                $cat_id = $_GET['cat_id'];

        }else{

                $cat_id = 1;
        }

if(isset($_GET['delete_cat_id'])){
       
        $delete_cat_id = $_GET['delete_cat_id'];
        if($query = $db->query("CALL delete_category_node($delete_cat_id);") === TRUE){

                        echo "Category Deleted";

        $query->close();
        }
}

        //GET CATEGORIES BY NODE
        $sql = "CALL get_category_nodes($cat_id);";
        $query = $db->query($sql);
        if ( !$query ) {
            echo '<div>Error: ', $db->error, '</br>Query: ', htmlentities($sql), "</div>\n";
                die();
        }       

        $row = $query->fetch_array(MYSQLI_ASSOC);

                while($row = $query->fetch_array(MYSQLI_ASSOC)){

                        echo "<a href=?cat_id=" . $row['category_id'] . ">" . $row['name'] . "</a> [ <a href=\"?delete_cat_id=" . $row['category_id'] . "\">x</a> ]<br/>";
        }
        $query->close();


        //GET ALL CATEGORIES
        $sql = "CALL get_categories();";
        $query = $db->query($sql);
                if ( !$query ) {
                echo '<div>Error: ', $db->error, '</br>Query: ', htmlentities($sql), "</div>\n";
                die();
                }
               
        $row = $query->fetch_array(MYSQLI_ASSOC);
                while($row = $query->fetch_array(MYSQLI_ASSOC)){
               
                        echo "<a href=?cat_id=" . $row['category_id'] . ">" . $row['name'] . "</a> [ <a href=\"?delete_cat_id=" . $row['category_id'] . "\">x</a> ]<br/>";
        }
        $query->close();




$db->cl

Link to comment
https://forums.phpfreaks.com/topic/48329-error-commands-out-of-sync/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.