TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   PDO Class problem (http://www.talkphp.com/advanced-php-programming/5871-pdo-class-problem.html)

newwarrior 05-22-2011 01:52 PM

PDO Class problem
 
Hello,

I have a little problem with a class that I used for my website, where the user could register.

This is the part for DB Connection:

PHP Code:

$dbh = new PDO("mysql:host=$DB_DATA_HOST;dbname=$DB_DATA_DATABASE"$DB_DATA_USER$DB_DATA_PASSWORD); 

This is the call for my class:

PHP Code:

//CREATE NEW CREATE OBJ
$create_user = new user($dbh);
$create_user->USERNAME $_POST['username'];
$create_user->PASSWORD md5($_POST['password']);
$create_user->EMAIL $_POST['email'];
$create_user->REGISTER_DATE time();

if(
$create_user->createUser())
    
$content_var .= $MESSAGE_SUCCESS['register']; 

This is my class (part of):

PHP Code:

public function __construct($dbh)
{
$this->dbh $dbh;
}

public function 
createUser()
{
$ZERO 0;
$this->OPERATION true;
$this->ACTIVATE_KEY $this->createRandomKey(25);

$sth $this->dbh->prepare('INSERT INTO user(username, password, email, active, activate_key, register_date) VALUES(?,?,?,?,?,?)');
$sth->bindParam(1$this->USERNAMEPDO::PARAM_STR);
$sth->bindParam(2$this->PASSWORDPDO::PARAM_STR);
$sth->bindParam(3$this->EMAILPDO::PARAM_STR);
$sth->bindParam(4$this->ZEROPDO::PARAM_INT);
$sth->bindParam(5$this->ACTIVATE_KEYPDO::PARAM_STR);
$sth->bindParam(6$this->REGISTER_DATEPDO::PARAM_INT);
$sth->execute(); 

The problem is, that there is no DB entry.
I get no error message or notice message.
I don't find the problem.

Could you maybe help me?

wGEric 05-26-2011 05:23 PM

Check to see if $sth->execute() is returning true or false. If it is false then there was an error and you should use PDOStatement->errorInfo() to get the error message.


All times are GMT. The time now is 11:24 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0