troubleshooting Question

PHP incomplete object

Avatar of jonlondon12
jonlondon12 asked on
10 Comments1 Solution3232 ViewsLast Modified:

I am trying declaring some classes like so, and making a ShoppingCart class in a $_SESSION[], like so:

      ini_set("include_path", "../../includes/");

            $cart = new ShoppingCart();

when I try and call a method of the class, like so:


I get the following error:

Fatal error: main() [function.main]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "ShoppingCart" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in C:\Program Files\xampp\htdocs\ewizadm\sites\b1477235\index.php on line 166

Please Help!!!

The ShoppingCart class is looks like this:


class ShoppingCart{
      private $vatRate=17.5;
      private $products;
      private $totalPrice;
      private $totalVAT;

      function addProduct($prodName){
            //add the image to the array
            $product = new Product();

      function getProduct($index){
            //add the image to the array
            return $this->products[$index];
      function getPriceWithoutVAT(){
            return $totalPrice * (100 - $this->vatRate);

      function getTotalVAT(){
            return $totalPrice * $this->vatRate;

      function getTotalPrice(){
            return $totalPrice;
      function outputSideCart(){
            echo "cool";
      function outputMainCart(){



Thanks for looking
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros