MySQLi在while循环中准备了查询

时间:2014-07-06 13:17:42

标签: php mysqli prepared-statement

我已经在while循环上进行了preapred查询,我希望当我从已经preapred获取数据时,在while循环中使用它进行查询,但是我得到了这个错误:致命错误:调用成员函数bind_param()在----

中的非对象上

这是我的代码:

<?php
        $query = $mysqli_conn->prepare("SELECT id,cvjecara_u,stock_id,kolicina,novca,datum FROM narucio ORDER BY id DESC");
        $query->execute();
        $query->bind_result($db_id,$db_cvjecara_u,$db_stock_id,$db_kolicina,$db_novca,$db_datum);

        while($query->fetch()){
            $c_id = $db_stock_id;
            $queryy = $mysqli_conn->prepare("SELECT naziv,kolicina2 FROM stock WHERE id = ?");
            $queryy->bind_param('i',$c_id);
            $queryy->execute();
            $queryy->bind_result($db_naziv,$db_kolicina2);
            $queryy->fetch();

            echo $db_cvjecara_u.$db_naziv.$db_kolicina.$db_kolicina2.$db_novca.$db_datum;
            $queryy->close();
        }
        $query->close();

        ?>

0 个答案:

没有答案