Mysql query class
Posted: Fri Aug 22, 2008 1:03 pm
I'm trying to learn how classes work. And this is what i worked up. And here is my error
Notice: Undefined variable: first_last in /mailer.php on line 20
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
The goal of this is to take first_last retrieve the row from the db that has firsT_last in it, then pull email from that row and print email on the screen.
Any advice would be appreciated.
Thanks
Notice: Undefined variable: first_last in /mailer.php on line 20
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
The goal of this is to take first_last retrieve the row from the db that has firsT_last in it, then pull email from that row and print email on the screen.
Any advice would be appreciated.
Code: Select all
class sendmail {
var $first_last;
var $query;
var $row;
var $result;
var $email;
var $con;
function query($firs_last)
{
$this->con = mysql_connect("localhost","admin","") or die("con line");
$this->db = mysql_select_db("contacts",$this->con) or die("error in db line");
$this->name = $first_last;
$this->query = "SELECT email FROM contacts WHERE first_last=".$this->name."";
$this->result = mysql_query($this->query) or die(mysql_error());
$this->row = mysql_fetch_array($this->result) or die(mysql_error());
//$this->email = $this->row;
$this->email = "EMAILLL";
}
}
$sendm = new sendmail();
$first_last = "john_doe";
$sendm->query($first_last);