Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Globals Inside Functions

Recommended Posts

I've got the following function, that has a function inside of it, when I run it I get the followin error:

PHP Code:

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


See the code below where I get the error message. I'm guessing the scope of my varaibles is messed up, but I'm not sure how to fix it. I've abbreviated the code so as to make it easier to read.

PHP Code:
function getMemberRegistrationForm( &$tpl, &$db ){    function displayRegistrationForm( $action, &$db, $defaults = NULL, $id = NULL )    {        global $registrationForm;            $registrationForm = new HTML_QuickForm('registrationForm');        $registrationForm->addElement('text', 'lname', 'Last Name:', array('size' => 40, 'maxlength' => 255 ));    }        if( $registrationForm->validate() ) // <-This is where I get an error    {        $registrationForm->freeze();    }    else    {        displayForm( $registrationForm, $tpl, 'additional_content');    }}getMemberRegistrationForm( $tpl, $db);

Thanks,kvarnerexpress

Share this post


Link to post
Share on other sites

First of all, sorry if i confuse you, i dont work with such codes (->,=>)Shouldn't the call to validate() need variables provided to send to ?Check if you defined all your functions correctly, check the following:*validate()*freeze()*displayForm()Hope this helps, even a little bit :/

Share this post


Link to post
Share on other sites

hi, kvarnerexpress i dont think that a function can within another function. but following the error displayed, it should be mean you have try to call an method but that method not included in a object ==> the HTML_QuickForm might not be a class. try search if it found HTML_QuickForm class or not.- hope this help

Share this post


Link to post
Share on other sites

All I can think of is if validate() is a function that exists (and your other functions also exist) when the getMemberRegistrationForm() function executes...Sorry I can't help much...but good luck!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.