从选择问题插入MySql

I have a small shopping cart with an option to create lists of products that you can use later for fast checkout. The addListToCart function adds a created product list to a shopping cart. The addListToCart function works only for one list. If you want to insert another list of products to the cart it doesn'tm and no error.
How can I fix this?

  function addListToCart($list){
    global $mysql;
    $idCart = $this->idCart();
    $data = date('Y-m-d H:i:s');
    $cod = $this->getCodProdus($produs);
    $titlu = $this->getNumeProdus($produs);
    $prettotal = $this->getPretProdus($produs);
    $pretunitar = $this->getPretUnitar($produs);
    $pretredus = $this->getPretRedus($produs);
    $gramaj = $this->getGramaj($produs);
    $tva = $this->getTVA($produs);

    if($idCart == 0){
        $idCos = $mysql->insert(sprintf("INSERT INTO cosuri SET status = 'open', 
                                                     phpsessid = '%s', 
                                                     uid = '%d', 
                                                     data = '%s'", 
                                                     $this->phpid,
                                                     $this->uid,
                                                     $data));

        $mysql->insert(sprintf("INSERT INTO comenzi (produs, 
                                                     titlu,
                                                     cantitate,
                                                     prettotal,
                                                     pretunitar,
                                                     pretredus,
                                                     gramaj,
                                                     tva,
                                                     data,
                                                     cos,
                                                     cod) 
                                SELECT p.id, 
                                       p.titlu, 
                                       lgp.cantitate, 
                                       p.prettotal, 
                                       p.pretunitar, 
                                       p.pretredus, 
                                       p.gramaj, 
                                       p.tva, 
                                       now(), 
                                       '%d',
                                       lgp.product_code 
                                FROM produse p
                                LEFT JOIN list_group_products lgp on p.cod=lgp.product_code
                                WHERE group_id='%d' AND p.vizibil=1", $idCos, $list));

    }else{

        $mysql->insert(sprintf("INSERT INTO comenzi (produs, 
                                                     titlu,
                                                     cantitate,
                                                     prettotal,
                                                     pretunitar,
                                                     pretredus,
                                                     gramaj,
                                                     tva,
                                                     data,
                                                     cos,
                                                     cod)  
                                SELECT p.id, 
                                       p.titlu, 
                                       lgp.cantitate, 
                                       p.prettotal, 
                                       p.pretunitar, 
                                       p.pretredus, 
                                       p.gramaj, 
                                       p.tva, 
                                       now(), 
                                       '%d',
                                       lgp.product_code
                                FROM produse p
                                LEFT JOIN list_group_products lgp on p.cod=lgp.product_code
                                LEFT JOIN comenzi c on p.cod=c.cod
                                WHERE c.cos='%d' AND lgp.group_id='%d' AND p.vizibil=1 ON DUPLICATE KEY UPDATE cantitate = c.cantitate + 1", $idCart, $idCart, $list));

    }
}