I am using pdo in php and the error i am getting is:
Product sub variant: Product: (
Fatal error: Call to a member function prepare() on a non-object
i have this piece of code in a class and i call it in php, the class is included in the page im calling it.
function get_variantname($variant_id)
{
$query = $db->prepare("select parent_attribute_label from tbl_parent_attribute where parent_attribute_id = :variant_id");
$query->bindParam(":variant_id", $variant_id);
$query->execute();
while($row = $query->fetch(PDO::FETCH_OBJ))
{
return $row->parent_attribute_label;
}
}