Can't get Insert to work from one class to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaulMilo
    New Member
    • Oct 2006
    • 1

    Can't get Insert to work from one class to another

    Hi
    I have a DB class which makes a connection and provides a method to send in queries as follows:
    function query($sql)
    {
    $this->result = @mysql_query($s ql, $this->conn);
    return($this->result != false);
    }
    I have an INSERT class that does this:
    class INSERT
    {
    var $username = '';
    var $password = '';
    var $tablename = '';

    function insert($usernam e,$password,$ta blename)
    {
    $insertquery = "insert into" . $tablename . "(secLoginID,se cPassword) values (" . $username . "," . $password . ")";
    function doInsert (){return $this->insertquery; }
    }
    }
    and I have a test page that does this:
    if ($db){
    $myinsert = new INSERT(paul,mik e,security);
    $db->query('$myinse rt->doInsert');
    $myaffected = $db->affectedRows() ;
    echo("number of affected rows is " . $myaffected . "<br><br>") ;
    } ELSE {
    die($db->error());
    }
    the affected rows function already works and is telling me that the insert is not happening.

    can anyone see what's wrong ?

    thx,

    Paul
Working...