Re: Quickform: problem with register globals on

From: Date: Fri, 14 Mar 2003 12:44:12 +0000
Subject: Re: Quickform: problem with register globals on
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4240@lists.php.net to get a copy of this message
<jeroen@terena.nl> wrote : > Hi, > > I've finally found the error that has been bugging me for a couple of > hours now. My quickform code gives me an error on my live server but > works fine on my development machine. > > Fatal error: Call to a member function on a non-object in > /usr/local/share/php/pear/HTML/QuickForm/group.php on line 272 > > It turns out I accidently put register globals "On" on my live server > and that casuses the error. I switched it off again, which is better > anyway, and the error is gone. I don't know if you could call this a > bug. Anyway, here's the code (simplified readability) I'm using > QuickForm 2.10. I > > <html><body> > <?php > require_once('HTML/QuickForm.php'); > $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : > 'default'; > > $form = new HTML_QuickForm('event', 'post'); > $form->addElement('hidden','action','update'); > > $form->addElement('text','city','City',array("size"=>45,"maxlength"=>100)); > $start['hour'] = > &HTML_QuickForm::createElement('select','hours',null,array(1,2,3)); > $start['min'] = > &HTML_QuickForm::createElement('select','mins',null,array(4,5,6)); If you use $start for both the group name and the array you want to fill the group with, then (with globals on) one of them will be overwritten and you will loose its values. I suggest you change $start to $startEl or whatever. BTW, you should also check if $_REQUEST is only set with globals on. > $form->addGroup($start, 'start', 'Starts', '&nbsp;'); > > $form->addElement('submit',null,'Submit',array("class"=>"submit")); > $form->addRule('city', 'City is required', 'required'); > > if ($action=='update') { > if ($form->validate()==true) { > $form->freeze(); > } > } > $form->display(); > ?> > </body></html> > > The validation method causes the error. > > - Jeroen >

« previous php.pear.general (#4240) next »