TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-22-2011, 01:52 PM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: May 2011
Location: Germany
Posts: 1
Thanks: 0
newwarrior is on a distinguished road
Default 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?
Send a message via ICQ to newwarrior Send a message via Skype™ to newwarrior
newwarrior is offline  
Reply With Quote
Old 05-26-2011, 05:23 PM   #2 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

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.
__________________
Eric
wGEric is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using one class within another - class v instance JohnAtYM Advanced PHP Programming 1 05-18-2010 11:05 AM
base classes..... allworknoplay Absolute Beginners 16 05-10-2009 08:09 PM
A Generic Singleton Base Class Theo Advanced PHP Programming 7 08-18-2008 02:25 AM
[Tutorial] Basic tutorial about class basics Tanax Absolute Beginners 14 07-24-2008 01:37 PM
PHP5 Classes A to Z Part 1 quantumkangaroo Advanced PHP Programming 11 04-01-2008 04:21 AM


All times are GMT. The time now is 09:09 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design