Fatal error: Call to a member function on a non-object in

Discussion in 'PHP' started by rushy, Dec 29, 2007.

  1. #1
    Hi Guys,

    Anyone know what causes this message and how I could possibly go about troubleshooting it?

    "Fatal error: Call to a member function on a non-object in /home/url etc"

    The actual line that it portains to is the 2nd one down:

    session_start();
    	if(isset($_SESSION["member"]["id"])){
    		$memberid=$_SESSION["member"]["id"];
    		$hasOrdered = $orderTable->count("WHERE member_id='$memberid' AND status!='pending'")>0;
    	}
    Code (markup):
    Any help appreciated!!
     
    rushy, Dec 29, 2007 IP
  2. coches

    coches Peon

    Messages:
    41
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    it usually means you try to use some method of a class not instantiated
     
    coches, Dec 29, 2007 IP
  3. rushy

    rushy Peon

    Messages:
    251
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for that, so with that in mind, and considering I am new to PHP, in my statement above, what may not have been instantiated?

    And how could I go about trying to resolve it?

    Thanks
     
    rushy, Dec 29, 2007 IP
  4. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #4
    $orderTable is not instantiated
     
    Dagon, Dec 29, 2007 IP
  5. rushy

    rushy Peon

    Messages:
    251
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks. Can someone tell me in psuedo what the entire statement is actually trying to achieve?

    I get the part about the site starting a session and trying to identify if a member has already been set with a session ID, but what is
    $hasOrdered = $orderTable->count("WHERE member_id='$memberid' AND status!='pending'")>0;
    Code (markup):
    trying to do?

    Then the statement ends...and of course it returns a fatal error...
     
    rushy, Dec 29, 2007 IP
  6. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #6
    it checks the ordertable if this member has placed at least one order already
     
    Dagon, Dec 29, 2007 IP
  7. rushy

    rushy Peon

    Messages:
    251
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    AH thanks, so in theory...if a session is still active via the first statement, there is no need for the second as the rule in the first statement (ID assigned to [member] [id]) should keep the contents of the cart intact?

    What practical advantage would be gained from storing whether the user has placed an order already?
     
    rushy, Dec 29, 2007 IP
  8. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #8
    giving him discount on his next order maybe?

    just an idea...
     
    Dagon, Dec 29, 2007 IP
  9. rushy

    rushy Peon

    Messages:
    251
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks for the help.

    Ok, I managed to get the error to stop appearing by commenting out the line in question, but instead of returning the user to the page in question (which you can see from the code below), it is just sending th euser back to the homepage of the site...

    Can anyone help me get this working so that the user is returned to the appropriate thank you page in the code below?

    <?php
    	require_once("info.php");
    	require_once("Table.php");
    	require_once("FrontView.php");
    	require_once("Controller.php");
    	require_once("CartBoxAction.php");
    	//contorl
    	//install cart
    	
    	
    session_start();
    	if(isset($_SESSION["member"]["id"])){
    		$memberid=$_SESSION["member"]["id"];
    		$hasOrdered = $orderTable->count("WHERE member_id='$memberid' AND status!='pending'")>0;
    	}
    	
    	
    	//contorl this page action
    	
    	
    	
    	//check member who ordered
    	
    	
    	
    	$view = new FrontView();
    	
    	$view->isLogged = isset($memberid);
    	$view->hasOrdered = $hasOrdered;
    	
    	
    	
    	echo $view->render("payment-confirm-view.php");	
    ?>
    Code (markup):
    If i comment out the $hasOrdered above, could this cause the page to skip past the 'render' part of the code straight to the homepage?

    Thanks for all help so far
     
    rushy, Dec 30, 2007 IP
  10. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #10
    I think the error is secondary to another problem so you'll have to track that down first.
     
    Dagon, Dec 30, 2007 IP
  11. rushy

    rushy Peon

    Messages:
    251
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Any tips on where to start?

    :)
     
    rushy, Dec 30, 2007 IP
  12. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #12
    Whats in the other scripts?
     
    HuggyStudios, Dec 30, 2007 IP
  13. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    don't comment out $hasOrdered because it is used for the $view better find out whether $orderTable has been instantiated. look for something like "$orderTable = new something();" in the script or the other scripts that was included in the script.
     
    kendo1979, Dec 30, 2007 IP