Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Archived

This topic is now archived and is closed to further replies.

Guest

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

Recommended Posts

Guest

Hmm i get this for the application_top.php for the cataloge

 

 

The offending lines are

// navigation history

 if (tep_session_is_registered('navigation')) {

   if (PHP_VERSION < 4) {

     $broken_navigation = $navigation;

     $navigation = new navigationHistory;

     $navigation->unserialize($broken_navigation);

   }

 } else {

   tep_session_register('navigation');

   $navigation = new navigationHistory;

 }

 $navigation->add_current_page();

 

Anyone got any ideas?

Share this post


Link to post
Share on other sites

After wresting briefly with this problem, I found the solution. The problem is that in some configurations (at least mine), the navigation history section in "application_top.php" doesn't catch the possibility that the session "navigation" variable is registered and the PHP version running is 4 or above. I'm really not quite sure what caused this huge oversight on the part of the developers (with all due respect).

 

Change the nagivation history chunk of code to read:

 

// navigation history
 if (tep_session_is_registered('navigation')) {
   if (PHP_VERSION < 4) {
     $broken_navigation = $navigation;
     $navigation = new navigationHistory;
     $navigation->unserialize($broken_navigation);
   } else {
	 $navigation = new navigationHistory;
 }
 } else {
   tep_session_register('navigation');
   $navigation = new navigationHistory;
 }
 $navigation->add_current_page();

 

and it should work just fine.

Share this post


Link to post
Share on other sites
Guest

I don't know, but I was using PHP 5, and because a payment module I had to imigrate to an ASP server (php compatibility installed).

 

After this change, the error apearred..

 

Thank you for the code correction!

It is all right now!!!

Share this post


Link to post
Share on other sites

DragonEyeDesign's code is incorrect and will cause a new problem of your navigation history continually getting erased. This is the correct fix:

 

// navigation history
if (tep_session_is_registered('navigation')) {
  if (PHP_VERSION < 4) {
 $broken_navigation = $navigation;
 $navigation = new navigationHistory;
 $navigation->unserialize($broken_navigation);
  } elseif (!is_object($navigation)) {
 $navigation = new navigationHistory;
  }
} else {
  tep_session_register('navigation');
  $navigation = new navigationHistory;
}
$navigation->add_current_page();


Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.

Share this post


Link to post
Share on other sites

wow,

 

That is a wonderful fix, I was scratching my head after I just installed a contribution which caused this error.

 

Thanks once again for the fix.

Share this post


Link to post
Share on other sites
DragonEyeDesign's code is incorrect and will cause a new problem of your navigation history continually getting erased. This is the correct fix:

 

// navigation history
if (tep_session_is_registered('navigation')) {
  if (PHP_VERSION < 4) {
 $broken_navigation = $navigation;
 $navigation = new navigationHistory;
 $navigation->unserialize($broken_navigation);
  } elseif (!is_object($navigation)) {
 $navigation = new navigationHistory;
  }
} else {
  tep_session_register('navigation');
  $navigation = new navigationHistory;
}
$navigation->add_current_page();

 

yes, this code is right!!

Many Thanks!

 

Best Regards,

Share this post


Link to post
Share on other sites

DragonEyeDesign's code is incorrect and will cause a new problem of your navigation history continually getting erased. This is the correct fix:

 

// navigation history
if (tep_session_is_registered('navigation')) {
  if (PHP_VERSION < 4) {
 $broken_navigation = $navigation;
 $navigation = new navigationHistory;
 $navigation->unserialize($broken_navigation);
  } elseif (!is_object($navigation)) {
 $navigation = new navigationHistory;
  }
} else {
  tep_session_register('navigation');
  $navigation = new navigationHistory;
}
$navigation->add_current_page();

I strongly recommend this code! :rolleyes: it solved the problem perfectly. that is, the navigation history is still there.

I've tried other code. they looks like solved the problem, but actually the navigation history has lost!

Share this post


Link to post
Share on other sites

This bug, which will evidently never be fixed, has been discussed many times:

http://www.oscommerce.com/forums/index.php?showtopic=346007

http://www.oscommerce.com/forums/index.php?showtopic=168369

http://www.oscommerce.com/forums/topic/168369-call-to-member-function-or-a-non-object/page__st__20

 

Did you look at all of these? The fix I've seen recommended most often (although there's no official word whether it's the right one) is

// navigation history
 if (tep_session_is_registered('navigation') && is_object($navigation)) {
   if (PHP_VERSION < 4) {
     $broken_navigation = $navigation;
     $navigation = new navigationHistory;
     $navigation->unserialize($broken_navigation);
   } else {
     $navigation = new navigationHistory;
   }
 } else {
   tep_session_register('navigation');
   $navigation = new navigationHistory;
 }
 $navigation->add_current_page();

Share this post


Link to post
Share on other sites

×