Jump to content

Fatal Error: Call to a member....


tet3828

Recommended Posts

I'm currently trying to inturpret and re-write a shopping cart script to integrate it into my site.
I am having a very hard time comprehending the script even though it came with a decent help file. This portion of the script is intended to display the cart after an item is added I take.
How ever after I use my "add item" button in my script I get this error...Reffering to the line of code  commented below.

The error:
[code]
Fatal error: Call to a member function on a non-object in /home/content/t/e/t/tetunity/html/shell/data/shop.php on line 186
[/code]
[b]I've paced a comment on line 186[/b]....
What is causing this error?... pls help. thx freaks

The script:
[code]
$total = 0;
$output[] = '<table>';
foreach ($contents as $id=>$qty) {
$sql = 'SELECT itemName,itemCat,itemSub,itemId,itemPrice,itemDesc,itemSmall FROM products WHERE itemId='.$id;
$result = $db->query($sql);           ///<----this line is getting the error
$row = $result->fetch();
extract($row);
$output[] = '<tr>';
$output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>';
$output[] = '<td>'.$title.' by '.$author.'</td>';
$output[] = '<td>&pound;'.$price.'</td>';
$output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';
$output[] = '<td>&pound;'.($price * $qty).'</td>';
$total += $price * $qty;
$output[] = '</tr>';
}
$output[] = '</table>';
$output[] = '<p>Grand total: &pound;'.$total.'</p>';[/code]
Link to comment
https://forums.phpfreaks.com/topic/30683-fatal-error-call-to-a-member/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.