尝试在描述页面上显示表格产品中的单个产品,但收到消息“试图获取非对象的属性”

I'm trying to display a particular product on a "description" page that comes from a products page if this makes sense, but all I get is this error "Trying to get property of non-object" so all I want is to get the selected product from a products page and display it in a description page... here is the code that I've used in my "more info" page, which is where the error is coming from, line 18* Just clarify that the imagename is a field from my table that contains the covers which are the link for the more info pages.

<?php
session_start();
require "dbconn.php";

$productImage = $_GET['imagename'];

$Imagename = $productImage;


$query = "SELECT * FROM products WHERE imagename =".$productImage;

$results = $connect->query($query);


if ($results->num_rows != 1)//Line 18
die ("Database did not return one result");
else
{
$row = $results->fetch_assoc();
}
?>

i guess imagename is a string, so it needs quotes around it.

$query = "SELECT * FROM products WHERE imagename = ' $productImage ' ";

$results = $connect->query($query);

if (!$results) die("error");

You just forgot to create the object $result like:

$result = new Something();

I suppose you created a class inside your "dbconn.php"...