daily pastebin goal
65%
SHARE
TWEET

1connection

kilykil Jun 18th, 2017 (edited) 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $database = new database;
  4.  
  5. ob_start();
  6. session_start();
  7.  
  8.     //dont show notice error
  9.     error_reporting(E_ALL & ~E_NOTICE);
  10.  
  11.     class database {
  12.  
  13.     private $pdo;
  14.  
  15.         public function __construct() {
  16.             // Connection information
  17.             $host = 'localhost';
  18.             $dbname = '';
  19.             $user = 'root';
  20.             $pass = '';
  21.      
  22.             // Attempt DB connection
  23.             try
  24.                 {
  25.                    
  26.                     $this->pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
  27.                     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  28.                   // check if db connection is succesful
  29.                   // echo 'Successfully connected to the database!';
  30.                 }
  31.                     catch(PDOException $e)
  32.                 {
  33.                     echo $e->getMessage();
  34.                 }
  35.  
  36.         }
  37. }
  38. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top