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:[EMAIL PROTECTED] 
        Sent: Wed 7/21/2004 1:45 AM 
        To: Scott Hyndman 
        Cc: [EMAIL PROTECTED] 
        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 <[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
        

Reply via email to