PHP Fatal error: Call to a member function on a non-object...

From: Date: Mon, 24 Nov 2003 16:07:40 +0000
Subject: PHP Fatal error: Call to a member function on a non-object...
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9109@lists.php.net to get a copy of this message
Hi, If I've got a class with a method that uses PEAR's Mail class, why wouldn't this work ??? // 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; } } 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 jon bennett | jon@jben.net new media designer / developer _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/

« previous php.pear.general (#9109) next »