Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Globals Inside Functions
kvarnerexpress
post Oct 26 2005, 12:03 PM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



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

PHP Code:
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:
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
Go to the top of the page
 
+Quote Post
dul
post Oct 27 2005, 11:36 PM
Post #2


Member [Level 1]
****

Group: Members
Posts: 73
Joined: 21-September 05
Member No.: 12,113



*BLEEP*ing hell. What is your registrationForm's source. Does it include that Validate() functuon???
Go to the top of the page
 
+Quote Post
HmmZ
post Oct 29 2005, 08:53 AM
Post #3


Super Member
*********

Group: Members
Posts: 362
Joined: 2-March 05
From: The Netherlands
Member No.: 4,097



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 :/

Go to the top of the page
 
+Quote Post
magiccode9
post Nov 3 2005, 09:13 AM
Post #4


Premium Member
********

Group: Members
Posts: 162
Joined: 1-November 05
From: SATA II
Member No.: 13,683



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
Go to the top of the page
 
+Quote Post
arboc7
post Nov 4 2005, 01:14 AM
Post #5


Advanced Member
*******

Group: Members
Posts: 123
Joined: 5-September 05
Member No.: 11,522



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!!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Functions To Send Mail(9)
  2. Functions(8)
  3. Pie Cakes (or, Pies Inside Of Cakes)(8)
  4. Watch Star Wars Inside Cmd(13)
  5. Cd Drive Eject Button Problem(3)
  6. Who's Fault Do You Think It Is?(2)
  7. Call Cookie Functions In Iframe(2)
  8. [php] Clean Code Functions(5)
  9. Functions(0)
  10. Wappy's Php Snippets(13)
  11. Vodafone New Zealand - Looks Good On The Outside But The Inside...(6)
  12. Create An Undeletable Shortcut Using Registry(windows)(1)
  13. Ajax Functions On Free Host(6)
  14. Can You Put Tables Inside Of Tables?(6)
  15. Php Email Validation(1)
  1. Life Talk! (hurting Inside)(8)
  2. Mysql Datatype Int() Question(1)
  3. Help: Disable All Buttons Inside A Div Element(8)
  4. Arrays Outside A Function(3)
  5. How Do Cameras Capture Pictures?(12)
  6. Inside Of A Processor(8)
  7. Start Your Garden Inside(28)
  8. The View From Inside A Recovering Suicidal(4)
  9. Encrypt Functions(0)
  10. -tlc- Bf2142 Clan Recruiting(0)
  11. Gta 4(6)
  12. Squishycash - Gpt Site With $3.00 Signup Bonus!(5)
  13. [php](simple) Using Functions To Combine Values In A Form(2)
  14. Web Designers Needed(7)
  15. Is It Possible To Align Text To The Center And Justify It?(6)


 



- Lo-Fi Version Time is now: 6th September 2008 - 06:14 PM