0

I'm having my first stab at OOP in PHP using PDO. I'm creating a log-in using a tutorial but having problems adding users to the database.

Here is my insert function(method) in my user class.

function registerUsers($username,$email,$password,$ip_address,$time,$date)
{
   $query = $this->link->prepare("INSERT INTO users (username,email,password,ip_address,date,time)VALUES (?,?,?,?,?,?)");
   $values = array($username,$email,$password,$ip_address,$date,$time);
   $query->execute($values);
   $counts = $query->rowCount();
   return $counts;
}

I'm guessing the issue is with the above code. My connection class is connecting to the database ok.

I wont post all the code here as its difficult to post large amounts of code on Stack with the spacing system they use so I have uploaded all my files here if you need a bigger picture: http://www.4shared.com/zip/PsQ7q73d/todo.html

You may also notice the error messages are not working either but I can ask that in another question if it's out of the scope of this question.

4

1 回答 1

0
function registerUsers($username,$email,$password,$ip_address,$time,$date) {
    try {
        $query = $this->link->prepare("INSERT INTO users (username,email,password,ip_address,date,time)VALUES (?,?,?,?,?,?)");
        $query->execute($username,$email,$password,$ip_address,$date,$time);
    } catch (PDOException $e) {
        print "Error!: " . $e->getMessage();
        return false;
    }
    return true;
}
于 2013-01-05T16:11:15.033 回答