SharkBait Posted June 26, 2007 Share Posted June 26, 2007 Perhaps I am doing this wrong (well obviously because it's not working) but... If I am using a function and I need to use a class object within it, should I pass the object also into the function? Would I pass the variable as an optional object? I get the following error: Fatal error: Call to a member function DoQuery() on a non-object in /home/tingram/public_html/feedback/includes/SendEmail.php on line 108 Which I assume is my $MySQL->DoQuery($strqry, $dblink) was not actually initialized in the function itself. Quote Link to comment https://forums.phpfreaks.com/topic/57287-using-a-class-within-an-function/ Share on other sites More sharing options...
KevinM1 Posted June 26, 2007 Share Posted June 26, 2007 Perhaps I am doing this wrong (well obviously because it's not working) but... If I am using a function and I need to use a class object within it, should I pass the object also into the function? Would I pass the variable as an optional object? I get the following error: Fatal error: Call to a member function DoQuery() on a non-object in /home/tingram/public_html/feedback/includes/SendEmail.php on line 108 Which I assume is my $MySQL->DoQuery($strqry, $dblink) was not actually initialized in the function itself. Please post the code in question. Quote Link to comment https://forums.phpfreaks.com/topic/57287-using-a-class-within-an-function/#findComment-283194 Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 Either make the object global inside the function or pass it as a parameter. Quote Link to comment https://forums.phpfreaks.com/topic/57287-using-a-class-within-an-function/#findComment-283458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.