Jump to content

I would like to acquire some help.


Lamez

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.