Lamez Posted August 23, 2010 Share Posted August 23, 2010 I am new to classes, I was returning to one of my forever long projects to return to this error: Notice: Undefined property: Database::$numRows in C:\Wamp\www\Webby\core\includes\Email.php on line 11 Here is line 11: if($q->numRows > 0){ After staring at it for an hour, I was hoping to find some help from you guys: <?php require_once("pear/Mail.php"); class Email extends Database{ var $from_name, $from_email, $to_name, $to_email, $subject, $body, $host, $port, $username, $password; private $db = NULL; function __construct(Database $db){ $this->db = $db; } function dbEmail($id, $name, $email, $subject, $body){ $q = $this->db->select(TBL_SMTP, "*", "id='".$id."'"); if($q->numRows > 0){ $f = $q->fetchRow(); $this->from_name = $f['name']; $this->from_email = $f['email']; $this->username = $f['username']; $this->password = $f['password']; $this->host = $f['protocol']."://".$f['server']; $this->port = $f['port']; $this->to_name = $name; $this->to_email = $email; $this->subject = $subject; $this->body = $body; return sendEmail(); }else return false; } function sendEmail(){ $from = $this->from_name." <".$this->from_email.">"; $to = $this->to_name." <".$this->to_email.">"; $headers = array ('From' => $this->from, 'To' => $this->to, 'Subject' => $this->subject); $smtp = Mail::factory('smtp', array ( 'host' => $this->host, 'port' => $this->port, 'auth' => true, 'username' => $this->username, 'password' => $this->password)); $mail = $smtp->send($to, $headers, $this->body); if(PEAR::isError($mail)){ //echo($mail->getMessage()); //For debugging purposes only return false; }else return true; } function addAccount($name, $email, $username, $password, $protocol, $port, $server){ //nothing yet.. } } $db = new Database(DB_HOST, DB_USER, DB_PASS, DB_DB); $email = new Email($db); ?> Link to comment https://forums.phpfreaks.com/topic/211466-i-would-like-to-acquire-some-help/ Share on other sites More sharing options...
trq Posted August 23, 2010 Share Posted August 23, 2010 The error is pretty self explanitory. NumRows is not a property of your $q object (whatever that is). What is returned by db->select() ? That is the object we need to see. Link to comment https://forums.phpfreaks.com/topic/211466-i-would-like-to-acquire-some-help/#findComment-1102580 Share on other sites More sharing options...
trq Posted August 23, 2010 Share Posted August 23, 2010 Also, why does Email extend Database? The two seem unrelated and your passing a Database object into Email anyway? Link to comment https://forums.phpfreaks.com/topic/211466-i-would-like-to-acquire-some-help/#findComment-1102581 Share on other sites More sharing options...
Lamez Posted August 23, 2010 Author Share Posted August 23, 2010 I feel so dumb. Fixed the extends database, and numRows was a function. Link to comment https://forums.phpfreaks.com/topic/211466-i-would-like-to-acquire-some-help/#findComment-1102582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.