On Tue, Mar 4, 2008 at 5:09 AM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote: > 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 > > He might not have loaded the class definition also. That'd lead to the nasty __PHP_Incomplete_Class. Or maybe it is something to do with class names in php4 weren't case sensitive whereas in php5 they are. I've used the unserialize_callback_func feature before to auto load classes. Oh I just read that Jim said this earlier, but I'm going to post it anyways after typing it up. ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php