TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-01-2008, 06:37 PM   #1 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default 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?
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-01-2008, 06:39 PM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Can you show us the code in question? I'm horrible as imagining things.
TlcAndres is offline  
Reply With Quote
Old 01-01-2008, 06:54 PM   #3 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default

Well, if they are in the same class, are you using self::drawHeaders() or $this->drawHeaders()?
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 01-01-2008, 07:03 PM   #4 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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!
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-02-2008, 08:56 PM   #5 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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:
function drawHeaders($reciever$additionalHeaders '') {
                foreach (
emailHeaders($reciever) as $headerKey => $headerValue) {
                    if (empty(
$headers)) {
                        
$headers $subheaderValue;
                    } else {
                        
$headers $headers.$subheaderValue;
                    }
                }
                if (
$additionalHeaders) {
                    foreach (
$additionalHeaders as $subheaderKey => $subheaderValue) {
                        if (empty(
$subheaders)) {
                            
$subheaders $subheaderValue;
                        } else {
                            
$subheaders $subheaders.$subheaderValue;
                        }
                    }
                }
                
                return (
$headers.$subheaders);
            } 
Part of the sendQueryError function inemail.class.php
PHP Code:
if (!empty($this->message)) {
                    
mail(    $this->reciever
                            
$this->subject
                            
$this->message
                            
$this->drawHeaders($this->reciever$this->addheaders), 
                            
$this->addparameters
                        
);        
                } 
Part of the mySQLQuery function in mysql.class.php
PHP Code:
if (!$this->queryResult) {
                        
$errorMessage  "<b>MySQL Retourneerde een Error.</b><br>";
                        
$errorMessage .= "<b>Error:</b> ".mysql_error()."<br>";
                        
$errorMessage .= "<b>Lijn:</b> ".$getLine."<br>";
                        
$errorMessage .= "<b>Bestand:</b> ".$getFile;
                        
$mail = new suRealityEmail;
                        
$mail->sendQueryError($errorMessage);
                        
$this->queryFailed++;
                    } 
And so, defined in index.php
PHP Code:
    require_once('includes/classes/mysql.class.php');
    require_once(
'includes/classes/email.class.php'); 
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-03-2008, 12:35 AM   #6 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

What's the exact error message?

And you're using the function emailHeaders without $this in the drawHeaders function maybe that's the problem?
sjaq is offline  
Reply With Quote
Old 01-03-2008, 06:03 AM   #7 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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?
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-03-2008, 04:36 PM   #8 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

I don't really see the problem..

Can you upload the whole files for us to check them?
sjaq is offline  
Reply With Quote
Old 01-03-2008, 05:41 PM   #9 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:29 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design