Wednesday, 14 December 2016

mysqli - Fatal error: Call to a member function fetch_assoc() on a non-object php mysql prepared statement




I have the following prepared statement for 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'].'
';
}



But It is showing fatal error as



Fatal error: Call to a member function fetch_assoc() on a non-object


Answer



try to debug yourself



I hope this will solve



$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.'
';
}
$product_info->close();

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...