![]() |
Classes: Function Usage
I seem to have caught myself at the classes again. I've made a function called drawHeaders(); which is defined first, in the top of the function.
Now, inside a function called sendMail(); I want to call up the drawHeaders but all it gives me is a Fatal error: Call to undefined function drawHeaders() drawHeaders gets, in a foreach loop, each header defined by the admin, and if defined by me in one of the documents (PHP), it foreach'es those as well and puts them into a variable which displays it correctly in the email's source. Can you guys help me out? |
Can you show us the code in question? I'm horrible as imagining things.
|
Well, if they are in the same class, are you using self::drawHeaders() or $this->drawHeaders()?
|
O MY GOD. I was using the crappy cache of DreamWeaver again. I saved and SAVED and SAAAVED but nothing happened, so I though I was beginning to get completely retarted.
I tried $this->drawHeaders(); the first time. It didn't work (obviously cache) so I tried another one, and another one, and another one. Anyways, it works now. Thanks for the simply and helpful post Andrew! |
Same problem again!
I've got 2 classes. email.class.php mysql.class.php In mySQL class, I've got an error report to be send to an email address using the email class. So, normally in the source I would define $mail->sendQueryError(); but it doesn't work. Now i've got $mail = new EmailClass; and later on $mail->sendQueryError. So, $this-> doesn't work, and it doesn't get the headers since a function for retrieving those is already defined in the email.class. The drawHeaders function in email.class.php PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
What's the exact error message?
And you're using the function emailHeaders without $this in the drawHeaders function maybe that's the problem? |
Fatal error: Call to a member function sendQueryError() on a non-object in C:\wamp\www\suReality\includes\classes\mysql.class .php on line 130
Line 130 states; $mail->sendQueryError($errorMessage); This is defined in the email.class.php as new suRealityEmail;, so it is ALWAYS defined when included/required. $this-> didn't work either. $this-> returned; Fatal error: Call to undefined method suRealityMySQL::sendQueryError() in C:\wamp\www\suReality\includes\classes\mysql.class .php on line 130 sendQueryError() is defined in the email.class.php, so it should be accessed since you use it in the SOURCE index.php, when BOTH are already included. You see the problem? |
I don't really see the problem..
Can you upload the whole files for us to check them? |
I figured out the problem. I had to create another instance of suRealityEmail since I am using an OTHER classes function, in a class. So, new suRealityEmail worked fine.
Hopefully I won't need any more help on this subject, but still I thought it was weird. |
| All times are GMT. The time now is 10:04 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0