بسم الله الرحمن الرحيم

الخطأ : Warning: mysqli_fetch_object(): Couldn't fetch mysqli_result

ماهي المشكلة في هذا الكود ؟

<?php

$product_id = $_GET['id'];

if($connect = mysqli_connect('localhost','root','','accounting')){

$sql = "SELECT * FROM inventory WHERE product_id='$product_id'";
$query = mysqli_query($connect,$sql);
mysqli_free_result($query);
mysqli_close($connect);

}else{ print "Connection failed"; }

while ( $fetch = mysqli_fetch_object($query) ) { print $fetch->id;

}

?>