I tell you something chaps this is killin me!
Fatal error: Call to a member function getName() on a non-object! I have posted this problem a few times but it keeps coming back to haunt me and I am losing faith in storing objects in sessions altogether!
Some of my classes have an update method that updates a Page, a Product, an Image etc via a
HTML front end. Now the Product class' update function works perfectly well, however the Page and Link class both give the Fatal Error. Each class uses the same process so it's baffling, plus all of the functions work perfectly on my local machine it's just my web server that is giving me grief!
This is the update function of the Page class:
- PHP: Select all
class Page{
...
function updatePage($_POST, $uri){
$userId=$_SESSION['user']->getUserId();
$_SESSION['page'] = unserialize($_SESSION['page']);
$pageName=$_SESSION['page']->getName();
$windowTitle=$_SESSION['page']->getWindowTitle();
$HTML=$_SESSION['page']->getContent();
serialize($_SESSION['page']);
***update code****
...
and the product class, which works uses the same process:
- PHP: Select all
class Product{
...
function updateProduct($_POST, $uri){
$_SESSION['product']=unserialize($_SESSION['product']);
$description = $_SESSION['product']->getDescription();
$shortDescription = $_SESSION['product']->getShortDescription();
$productName = $_SESSION['product']->getName();
$price = $_SESSION['product']->getPrice();
$images=$_SESSION['product']->getImageNamesArray();
$productInCats=$_SESSION['product']->getProdInCategoryAsArray();
$_SESSION['product']=serialize($_SESSION['product']);
***update code****
...
now I know the object is there because doing a var_dump($_SESSION) shows me the page object and its associated attributes. I am on PHP5 and I know register_globals is switched on with my host.I have taken the advice to include an autoload function as well to try and combat the problem but it still remains!
Please restore my faith in
PHP SESSION Objects.
If i have not made myself clear please feel free to ask me to post more code or more info.
Thanks a million!!