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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.