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 <[EMAIL PROTECTED]>
To:     Jason Barnett <[EMAIL PROTECTED]>


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to