致命错误:在非对象php mysql准备语句中调用成员函数fetch_assoc()

时间:2014-01-11 06:57:56

标签: php mysqli prepared-statement

我为select query

准备了以下语句
$product_info = $this->mysqliengine->prepare("select product_id, sku from product limit 10");
        $product_info->execute();
        $res = $product_info->bind_result();
        while($row = $res->fetch_assoc()) {
            echo $row['sku'].'<br />';
        }

但它显示致命错误

致命错误:在非对象上调用成员函数fetch_assoc()

1 个答案:

答案 0 :(得分:0)

尝试自己调试

我希望这会解决

$product_info = $this->mysqliengine->prepare("select product_id, sku from product limit 10");
        $product_info->execute();
        $product_info->bind_result($product_id,$sku);

        while($product_info->fetch()) {
            echo $product_id.'<br />';
        }
        $product_info->close();