我一直收到一条错误,说明这个函数的第78行

I am trying to retrieve items from database. But, I keep getting an error that says C:\xampp\htdocs\two\myitems.php on line 78

      $ownerid = $user->id; 

     function getItemsbyOwner($ownerid) {
                $db = new mysqli(DBHOST,DBUSER,DBPASS,DB);
                $query = "SELECT * FROM product WHERE owner = $ownerid";
                $result = $db->query($query);
                if (mysqli_num_rows($result) > 0) {
                $items = array();
                while($row = $result->fetch_array(MYSQLI_ASSOC)) {
  line 78:              $item = new Item($row['itemid'], $row['category'], $row['name'], $row['upload_date'], $row['owner'], $row['description'], $row['price'], $row['location'], $row['city'], $row['state'], $row['phone'], $row['negotiable'], $row['piclink']);
                array_push($items, $item);
                }
                $db->close();
                return $items;
                } else {
                $db->close();
                return NULL;
                }
                }

I have no idea what im doing wrong

this is the construct for the item class

<?php 
require('inc/dbstuff.inc.php');
require('ClassUser.php')

class Item{
    public $itemid;
    public $category;
    public $name;
    public $upload_date;
    public $owner;
    public $description;
    public $price;
    public $location;
    public $city;
    public $state;
    public $phone;
    public $negotiatable;
    public $piclink;

    function __construct($itemid, $category, $name, $upload_date, $owner, $description, $price, $location, $city, $state, $phone, $negotiatable, $piclink) {
        $this->itemid = $itemid;
        $this->category = $category;
        $this->name = $name;
        $this->upload_date = $upload_date;
        $this->owner = $owner;
        $this->description = $description;
        $this->price = $price;
        $this->location = $location;
        $this->city = $city;
        $this->state = $state;
        $this->phone = $phone;
        $this->negotiatable =$negotiatable;
        $this->piclink =$piclink;
    }

So, i'm trying to retrieve from database using a new item class. And, im getting this error.

How about this?

   $items = [];
    while($row = $result->fetch_array(MYSQLI_ASSOC)) {
        $items[] = $row;
    }