Thread: coder down

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Chicago, IL USA
    Posts
    48
    Rep Power
    18
    Hi, I just upgraded to php4.0.3pl1 and my session variables don't seem to want to carry data between pages when I initiate a class in a session variable. This is how I am doing it...

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    require("cartlib.php");

    if (! isset($SESSION)) {
    $SESSION = array();
    }

    if (! isset($SESSION["cart"])) {
    $SESSION["cart"] = new Cart;
    }

    session_start();
    session_register("SESSION");

    class object {};

    [/code]

    This seemed to work fine in php4.0.0 (except instead I called the $SESSION variable after I registered it). When I attempt to add data to the class like so...

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    $SESSION["cart"]->add($id, 1);
    $SESSION["cart"]->cleanup();
    $SESSION["cart"]->recalc_total();

    [/code]

    I get an error like this...


    Fatal error: Call to a member function on a non-object in shoppingcart.php on line 8


    ...to make it stranger sometimes it works sometimes it doesnt ??? very strange. please somebody help.

    Brendon

  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    session_start();
    >>


    Put this session_start() before your if statement and see how it works.

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

IMN logo majestic logo threadwatch logo seochat tools logo