PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 24th, 2003, 01:29 PM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
PHP Fatal error: Call to a member function on a non-object

Hi,

If I've got a class with a method that uses PEAR's Mail class, why wouldn't this work ???
PHP Code:
// mail_test.php

require_once("Mail.php");

class 
users // open the class definition

 /**
        * PEAR mail object
        *
        * @var object
        * @access private
        */
        
var $_oMail;
        
        
// CONSTRUCTOR ::::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::

        /**
        * class constructor
        *
        * @param integer user id [optional]
        * @access public
        */
        
function users(') {

                // implement pear mail object
                $this->_oMail =& Mail::factory("mail");

                if (PEAR::isError($this->_oMail)) {

                        catchExc($this->_oMail->getMessage());
                }

        }

        **
        * send email notification
        *
        * @param string $sBody email body
        * @return boolean
        * @access private
        */
        function _notifyUser($sBody) {

                // assign mail properties
                $aUser = $this->getUser();
                $aHeaders["To"] = $sRecipients = $aUser["Email"];
                $aHeaders["From"] = ENTITY." Admin <".EMAIL.">";
                $aHeaders["Subject"] = ENTITY." System Account Notification";
                $aHeaders["Priority"] = "3";

                // try to send mail
                if (PEAR::isError($mailTmp = $this->_oMail->send($sRecipients, $aHeaders, $sBody))) {
                        catchExc($mailTmp->getMessage());
                return false;
                }
                
                return true;
        }

/** 
     * deactivate a user record
     *
     * @return boolean
     * @access public
     */
    function deactivateUser() {
        
        $sql = "UPDATE ".PREFIX."_admin_users SET 
                    status=0 
                WHERE 
                    admin_user_id=".$this->_iUserId;
        
        if (DB::isError($rsTmp = $this->_oConn->query($sql))) {
            
            catchExc($rsTmp->getMessage());
            return false;
        }
        
        // build user email
        $sBody = "Your ".ENTITY." account has been deactivated.";
        
        return $this->_notifyUser($sBody);
    }



The notifyUser method is called from within the deleteUser method (and others)

The code above has been stripped down, but I always get this error when anything tries to call the notifyUser() method:

PHP Fatal error: Call to a member function on a non-object in /Library/WebServer/Documents/mail_test.php

If I remove the actual line that sends the email, then everything works fine, but, obviously, the email never gets sent!

why doesn't $this->_oMail appear to be part of the class ???? Is that the problem ??

Thanks in advance,

Jon

Reply With Quote
  #2  
Old November 24th, 2003, 01:30 PM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
Also, I'm not getting any include errors, so I'm assuming that's not the problem. Also, the Mail class is instansiated in the users class constructor function, and I don't ever get any errors there.

weird init

Jon

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP Fatal error: Call to a member function on a non-object


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT