RE: PHP5 - Weird Error - "cannot find element in variable"

From: Date: Wed, 21 Jul 2004 18:57:06 +0000
Subject: RE: PHP5 - Weird Error - "cannot find element in variable"
Groups: php.general 
Request: Send a blank email to php-general+get-191372@lists.php.net to get a copy of this message
Thanks, but that isn't the problem. I just rewrote the code wrong for the email. This is a PHP5 bug, I'm quite sure. I'm going to test under IIS, then give it a shot under linux. -----Original Message----- From: Jason Barnett [mailto:jasbarne@indiana.edu] Sent: Wed 7/21/2004 1:45 AM To: Scott Hyndman Cc: php-general@lists.php.net Subject: Re: PHP5 - Weird Error - "cannot find element in variable" Reply to the group, not just to me - there are a lot of people smarter than I on this list. Based on your class I can see that you're simply creating your objects with the wrong parameters - you've switched position and name. Just change your while loop to: while (!$res->EOF) { $f = $res->fields; // Position and name switched $collection->Add(new Amenity($f['position'], $f['name'], $f['context'])); $res->MoveNext(); } -------- Original Message -------- Subject: RE: [PHP] Re: PHP5 - Weird Error - "cannot find element in variable" Date: Wed, 21 Jul 2004 00:27:29 -0400 From: Scott Hyndman <Scott@affsys.com> To: Jason Barnett <jasbarne@indiana.edu> Overwriting at that index is intended. Object (Really called Amenity) is defined as such: class Amenity { public $position; public $name; public $description; public $context; public $state = AMENITY_STATE_INHERIT; /** * Creates a new Amenity instance */ public function Amenity($position, $name, $context) { $this->position = $position; $this->name = $name; $this->context = $context; } /** * Returns a string representation of the object * * Dependent on the value of the state member, ToString() returns * one of the following * - AMENITY_STATE_TRUE a "Y" is returned * - AMENITY_STATE_FALSE an "N" is returned * - AMENITY_STATE_INHERIT a "." is returned * * @returns string The string */ public function ToString() { switch ($this->state) { case AMENITY_STATE_TRUE: return "Y"; break; case AMENITY_STATE_FALSE: return "N"; break; case AMENITY_STATE_INHERIT: return "."; break; } } } As you can see, it is in order. Even now that I’ve removed the iterators, I’m still running into this problem when accessing the value of an array containing these objects (sometimes). Very strange behaviour! -Scott

« previous php.general (#191372) next »