Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Database {
- public $conn;
- protected $hostname;
- protected $username;
- protected $password;
- protected $dbname;
- public function __construct ( $hostname, $username, $password, $dbname ) {
- global $conn;
- $this->conn = $conn;
- $this->hostname = $hostname;
- $this->username = $username;
- $this->password = $password;
- $this->dbname = $dbname;
- $conn = new mysqli($hostname, $username, $password, $dbname) or die(('Could not connect to this hostname.' .$hostname. 'Error: ' . mysqli_connect_error() . $conn->connect_error);
- if ($conn == false) {
- trigger_error('Error connecting: ' . mysqli_connect_error() . $conn->error . $conn->errno, E_USER_ERROR);
- exit;
- }
- $conn->set_charset('utf8');
- }
- }
- // creating the object of connection.
- $db = new Database ( 'localhost', 'root', '', 'table_name' );
- // debug
- print '<pre>';
- print_r($db);
- print '</pre>';
- print '<pre>';
- var_dump($db);
- print '</pre>';
- print '<hr>';
- print '<pre>';
- print_r($conn);
- print '</pre>';
- print '<pre>';
- var_dump($conn);
- print '</pre>';
- print '<hr>';
- printf("<pre>%s</pre>",print_r($conn, true));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement