 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Blackmajik
Joined: 29 Feb 2008 Posts: 1
|
Posted: Fri Feb 29, 2008 10:48 pm Post subject: Newbie question on prepare and execute |
|
|
| Code: | <?php
require_once 'pear/MDB2.php';
require_once 'pear/PEAR.php';
class dbManager {
private static $dsn = array(
'phptype' => 'oci8',
'username' => 'stuff',
'password' => 'stuff',
'hostspec' => 'localhost',
);
private static $dbh;
public function __construct() {
dbManager::$dbh =& MDB2::connect(dbManager::$dsn);
if(PEAR::isError(dbManager::$dbh)) {
die(dbManager::$dbh->getMessage());
}
}
public function dbCreateAccount($username, $password) {
$types = array('text','text');
$sth = dbManager::$dbh->prepare('INSERT INTO users (username, password) VALUES (?, ?)', $types);
$data = array("$username","$password");
$rows = $sth->execute($data);
if(PEAR::isError($rows)) {
die($rows->getMessage());
}
}
public function dbDisconnect() {
dbManager::$dbh->disconnect();
}
}
?> |
I get the error MDB2 Error: not found. I was getting this error also when trying to make a connection to database but I fixed that. Now i get it when i use isError on rows. I'm not sure if its the prepare or the execute that is messing up. is this the correct way of using prepare and execute. I test the value of the variable $data throughout the function using echo and the values are always in there. If anyone has any debug techniques or know why this isn't working I thank you. I'm also beginning at php so if there is a better way to write this I would apprecite also.
Kyle[/quote] |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sat Mar 01, 2008 3:00 pm Post subject: |
|
|
You're getting this error because your require_once calls are wrong (simply 'MDB2.php' and 'PEAR.php' are correct; the latter isn't really needed BTW), and most likely because you haven't adjusted your include_path setting.
Using getDebugInfo() in addition to the getMessage() calls will give you more reasonable error messages with MDB2. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|