Warning: Illegal offset type

  • marvoh
  • Born
  • Born
  • marvoh
  • Posts: 3

Post 3+ Months Ago

Hi,
I have the following code in symphony and getting a 'Warning: Illegal offset type' for the last 3 lines. Anyone willing to rescue this stuck newbie?
PHP Code: [ Select ]
<?php $c = new Criteria();
    $this->addFiltersCriteria($c);
   $plans = DistributionPlanPeer::doSelect($c);
   $this->list = array();
   foreach ($plans as $r) {
      $cat = $r->getSubCategory();
      $id = $r->getId();
      $district = $r->getSettlementRelatedBySettlementId()->getDistrict()->getName();
   $this->list[$cat][$id]['district'] = $district;
   $this->list[$cat][$id]['settlement'] = $r->getSettlementRelatedBySettlementId()->getName();
   $this->list[$cat][$id]['agreement'] = (string)$r->getAgreement()->getAgreementNo();
}
?>
 
  1. <?php $c = new Criteria();
  2.     $this->addFiltersCriteria($c);
  3.    $plans = DistributionPlanPeer::doSelect($c);
  4.    $this->list = array();
  5.    foreach ($plans as $r) {
  6.       $cat = $r->getSubCategory();
  7.       $id = $r->getId();
  8.       $district = $r->getSettlementRelatedBySettlementId()->getDistrict()->getName();
  9.    $this->list[$cat][$id]['district'] = $district;
  10.    $this->list[$cat][$id]['settlement'] = $r->getSettlementRelatedBySettlementId()->getName();
  11.    $this->list[$cat][$id]['agreement'] = (string)$r->getAgreement()->getAgreementNo();
  12. }
  13. ?>
  14.  
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa
  • marvoh
  • Born
  • Born
  • marvoh
  • Posts: 3

Post 3+ Months Ago

being a novice, i count really relate my issue with the post on that page as none of my variables are empty
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Doesn't look like this is going to be a simple "you missed a letter" type of bug fix at first glance.

Somewhere within "DistributionPlanPeer::doSelect" you're getting an array of objects. What type of objects I'm not sure, but they have "getSubCategory" and "getId" methods.

It seems that one or both of those two methods is returning an object. Taking a shot in the dark here, are you working with XML in there somewhere ? Often times when working with XML people will forget (or just don't know) to type-cast the text nodes returned from xpath and friends, which can lead to these types of illegal offset errors.

If you're lucky, that's what it is, and you can try adding (string) before each of those variables where you try to use them as array offsets.

PHP Code: [ Select ]
$this->list[(string)$cat][(string)$id]['district'] = $district;
  • marvoh
  • Born
  • Born
  • marvoh
  • Posts: 3

Post 3+ Months Ago

:-), i've just spotted the culprit object.. thanks for being patient with me :-)

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 124 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.