Here is my code
<?php
class db extends PDO {
private $error; private $sql; private $bind; private $errorCallbackFunction; private $errorMsgFormat;
public function __construct($dsn, $user="", $passwd="") {
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
try {
parent::__construct($dsn, $user, $passwd, $options);
} catch (PDOException $e) {
$this->error = $e->getMessage();
}
}
But that line $this->error = $e->getMessage();
is showing error like this
Warning: Creating default object from empty value in C:\Program Files (x86)\Ampps\www\blog\library\class-database.php on line 14
I have created the code like this
$db = new db("mysql:host=localhost;port=3306;dbname=".$dbname, $dbusername, $dbpassword);
and for testing other value were correct except $dbname as i want to show user that they inserted incorrect database details.