Host config broke my code, please help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tarantulus
    New Member
    • May 2007
    • 114

    Host config broke my code, please help.

    Hi Guys/Girls,

    I have been coding a website for a friend, everything worked fine on my localhost setup, then I FTP to their host and now it's broken....

    the error is

    Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition cart of the object you are trying to operate on was loaded _before_ the session was started in /index.php on line 40

    line 40 of index.php is
    Code:
    $cart -> add($id,$qty,$price);
    and the necessary function is
    Code:
    function add($prod_id,$qty,$price) {
    		
    		
    			session_start();
    			
    		
    			if (isset ($_SESSION['cart'][$prod_id])){
    				$_SESSION['cart'][$prod_id]['qty'] += $qty;
    			} 
    			else{
    				$_SESSION['cart'][$prod_id] = array("qty"=>$qty,"price"=>$price);
    				
    			}
    		
    		
    	}
    can someone point out what I've done wrong??
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Tarantulus.

    'Incomplete Class' generally refers to a PHP-4-style class on a PHP 5 installation. Check your phpinfo() output and verify your friend's PHP version.

    Comment

    • Tarantulus
      New Member
      • May 2007
      • 114

      #3
      Originally posted by pbmods
      Heya, Tarantulus.

      'Incomplete Class' generally refers to a PHP-4-style class on a PHP 5 installation. Check your phpinfo() output and verify your friend's PHP version.
      funnily enough I have PHP 5.x and the host has 4.x AND 5.x but runs 4.x as default, which is where I first saw the error. this error comes up since I changed the .htaccess to use 5.x.

      Comment

      • Tarantulus
        New Member
        • May 2007
        • 114

        #4
        Originally posted by Tarantulus
        funnily enough I have PHP 5.x and the host has 4.x AND 5.x but runs 4.x as default, which is where I first saw the error. this error comes up since I changed the .htaccess to use 5.x.
        I just realised this post makes it sound like the problem was solved.

        I should say that it is broken in both PHP4 and PHP5, however the specific error I mentioned is with PHP5.

        it's driving me insane as it works on my PHP5 install without a hitch!

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          According to this comment:

          You get this error if you have and object in your $_SESSION array and you call session_start() before you have loaded your included classes.

          Try implementing an autoloader.

          Comment

          • Tarantulus
            New Member
            • May 2007
            • 114

            #6
            thanks for the pointers, turns out there was no problem with my code though... re-uploaded and it worked.

            thanks again

            Comment

            Working...