I have the following function which has both for and while loop to execute a prepared statement. But it is throwing error as Commands out of sync; you can't run this command now
Here is my function
public function queryProductDetail() {
$product_info = $this->mysqliengine->prepare("select product_id, sku from product limit 10");
$product_info->execute();
$product_info->bind_result($product_id,$sku);
$product_image = $this->mysqliengine->prepare("insert into product_image(product_id,thumb_image,medium_image,original_image) values(?,?,?,?)") or die($this->mysqliengine->error);
$product_image->bind_param('isss',$api_product_id, $thumb_image, $medium_image, $original_image);
while($product_info->fetch()) {
$rowResult = $this->api->queryProduct(array('serverParams' => array('sku' => $sku, 'usertoken' => USER_TOKEN)));
foreach($rowResult->result->imagesUrls->Image as $image) {
$api_product_id = $product_id;
$thumb_image = $image->smallurl;
$medium_image = $image->middleurl;
$original_image = $image->bigurl;
$product_image->execute();
}
}
}
Can anyone help me why this is happening.
This is the message Fatal error: Call to a member function bind_param() on a non-object
in $product_image->bind_param