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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.