I have this code trying to create a json file from sql database. the code prints out FINE but it is giving a warning saying
Warning: Creating default object from empty value in C:\xampp\htdocs\z\index.php on line 5
can any on fix the error for me. here is my code.
<?php include '../config.php';
$sth = mysqli_query($conn,"SELECT * from movies limit 4");
while($r = mysqli_fetch_assoc($sth)) {
$rows->id = $r['id'];
$rows->hidy = $r['hidy'];
}
print json_encode($rows);