Zen Cart Logo
Forums / General Questions / Fatal error: Call to a member function on a non-object

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

Locked

Views: 2,438

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
24 Jun 2006, 2:52 AM
#1
jonwil99 avatar

jonwil99

New Zenner

Join Date:
Nov 2004
Posts:
17
Plugin Contributions:
0

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

We have been running ZENCART for over 12 months now without a problem now when selecting certain root categories we get the message:

Fatal error: Call to a member function on a non-object in /hsphere/local/home/jedko/milsims.com.au/test/includes/classes/category_tree.php on line 70

Offending code snippet is:
class category_tree {

function zen_category_tree($product_type = "all") {
  global $db, $cPath, $cPath_array;
  if ($product_type != 'all') {
    $sql = "select type_master_type from " . TABLE_PRODUCT_TYPES . "
            where type_master_type = '" . $product_type . "'";
    $master_type_result = $db->Execute($sql);
    $master_type = $master_type_result->fields['type_master_type'];
  }
  $this->tree = array();
  if ($product_type == 'all') {
    $categories_query = "select c.categories_id, cd.categories_name, c.parent_id
                         from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                         where c.parent_id = '0'
                         and c.categories_id = cd.categories_id
                         and cd.language_id='" . (int)$_SESSION['languages_id'] . "'
                         and c.categories_status= '1'
                         order by sort_order, cd.categories_name";
  } else {
    $categories_query = "select ptc.category_id as categories_id, cd.categories_name, c.parent_id
                         from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCT_TYPES_TO_CATEGORY . " ptc
                         where c.parent_id = '0'
                         and ptc.category_id = cd.categories_id
                         and ptc.product_type_id = '" . $master_type . "'
                         and c.categories_id = ptc.category_id
                         and cd.language_id='" . (int)$_SESSION['languages_id'] ."'
                         and c.categories_status= '1'
                         order by sort_order, cd.categories_name";
  }
  $categories = $db->Execute($categories_query, '', true, 150);
  while (!$categories->EOF)  {
    $this->tree[$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'],
                                                'parent' => $categories->fields['parent_id'],
                                                'level' => 0,
                                                'path' => $categories->fields['categories_id'],
                                                'next_id' => false);

    if (isset($parent_id)) {
      $this->tree[$parent_id]['next_id'] = $categories->fields['categories_id'];
    }

    $parent_id = $categories->fields['categories_id'];

    if (!isset($first_element)) {
      $first_element = $categories->fields['categories_id'];
    }
    $categories->MoveNext(); // offending line 
  }

And the offending line is:

  $categories->MoveNext();

My PHP is not that great but I have done some looking around and have establised the following:

  1. If I go to the admin module and expand the offending category it looks OK
  2. Browsing the category tables look OK

Any help woulfd be much appreciated - thankyou
Jon

18 Oct 2006, 2:01 PM
#2
lxnuke avatar

lxnuke

New Zenner

Join Date:
Mar 2005
Posts:
1
Plugin Contributions:
0

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

got same problem but noticed in my old 1.2.4 version following difference (now 1.3.5) in line:

$categories = $db->Execute($categories_query, '', false, 150);

I changed it at the tree is working; i didn't found the explication of this parameter.
Perhaps anyone else may tell.