I get this error when I'm trying to call AutoPulldownMenu "Fatal error: Call to a member function on a non-object" does anyone know how to get around this?

$group = array();  
$group[] = new PullDownMenu; $group[1][0]->$name = "Boots"; $group[1][1]->$name = "English"; $group[1][0]->$value = 2; $group[1][1]->$value = 3; $group -> AutoPulldownMenu(eventfrm); class PullDownMenu { var $value; var $name; function AutoPulldownMenu($formName) { foreach ($this->name as $key => $value) { $b=0; foreach ($value as $key2 => $value2) { echo "group[$a][$b]=new Option(\"$value2\")\n"; $b++; } $a++; } } }

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

    If your code is exactly as posted the problem is probably this line:

    $group -> AutoPulldownMenu(eventfrm);
    

    Try replacing it with one of these two (I'm not sure which you need):

    $group -> AutoPulldownMenu($eventfrm);
    
    $group -> AutoPulldownMenu("eventfrm");
    

    Hope this helps 😉

      I don't think thats the problem, the problem is more that $group is an array and an object, because if I make a fake object like:

      $group2 = new PullDownMenu;     
      $group2 -> AutoPulldownMenu(eventfrm);

      It works fine. But I would like to be able to pass the object as an array.

        Why would you want to pass the object as an array?

        Why not pass an array of objects instead?

        $pulldown1 =& new PullDownMenu();
        $pulldown1->name = "Boots";
        $pulldown1->value = 2;
        
        $pulldown2 =& new PullDownMenu();
        $pulldown2->name = "English";
        $pulldown2->value = 3;
        
        $group = array();
        $group[0] =& $pulldown1;
        $group[1] =& $pulldown2;
        
          Write a Reply...