maxhugen Posted March 24, 2009 Share Posted March 24, 2009 I have a php function that fills in a number of text boxes etc in a form. However, there are several forms and web pages involved, and some forms will NOT have all of the text boxes. Thus, I need my function to test if a control actually exists. Currently, I do something like: $Component->$grpatt->SetValue($db->f('attribute')); If the text box control ($grpatt) doesn't exist, I get PHP Fatal error: Call to a member function SetValue() on a non-object. I looked at isset() but that doesn't seem right... and I couldn't get it to work when I tried it anyway. I'm really stuck here, can't go any further till I fix this, so any suggestions would be most appreciated! MTIA Quote Link to comment https://forums.phpfreaks.com/topic/150975-prevent-fatal-error-on-non-object/ Share on other sites More sharing options...
WolfRage Posted March 24, 2009 Share Posted March 24, 2009 property_exists () : http://us3.php.net/manual/en/function.property-exists.php or maybe this method_exists() : http://us3.php.net/manual/en/function.method-exists.php Quote Link to comment https://forums.phpfreaks.com/topic/150975-prevent-fatal-error-on-non-object/#findComment-793179 Share on other sites More sharing options...
maxhugen Posted March 25, 2009 Author Share Posted March 25, 2009 Thanks! I don't know what I did wrong when I first tried it, but I got isset() to work OK now. I'll remember your method_exists() tip though, should be useful. Cheers, Quote Link to comment https://forums.phpfreaks.com/topic/150975-prevent-fatal-error-on-non-object/#findComment-793971 Share on other sites More sharing options...
WolfRage Posted March 26, 2009 Share Posted March 26, 2009 No Problem, Mark Solved. Quote Link to comment https://forums.phpfreaks.com/topic/150975-prevent-fatal-error-on-non-object/#findComment-794543 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.