Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $database = new database;
- ob_start();
- session_start();
- //dont show notice error
- error_reporting(E_ALL & ~E_NOTICE);
- class database {
- private $pdo;
- public function __construct() {
- // Connection information
- $host = 'localhost';
- $dbname = '';
- $user = 'root';
- $pass = '';
- // Attempt DB connection
- try
- {
- $this->pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
- $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- // check if db connection is succesful
- // echo 'Successfully connected to the database!';
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement