Ben Edwards schreef:
Our server has just been upgraded to PHP 5.2.5 and suddenly I am
getting the following error:

Fatal error:  Call to a member function web_order_change() on a
non-object in /var/www/vhosts/cultureshop.org/httpdocs/cart.php on
line 32

The code is:

$SESSION["cart"]->web_order_change( true );

The command 'global $SESSION;' is the first line of the script.


$SESSION is the session variable created with

session_start();
session_register("SESSION");

don't use session_register(), use the $_SESSION superglobal instead
(notice the underscore) ... you can read in the manual about this.

additionally you need to load in the class before you start the
session.

so the code would look something like:

require 'Cart.class.php';
session_start();

if (!isset($_SESSION['cart']))
        $_SESSION['cart'] = new Cart;

function foo()
{
        // no need to use global on $_SESSION
        $_SESSION["cart"]->web_order_change( true );
}


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

I am guessing this is a change in OO handling, any idea what is going
on and how to fix it?

the crux of the problem lies in the use of outdated session semantics, I'm
guess you've just been upgrade from 4.x, is that correct?


Regards,
Ben


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to