Advertisement
Guest User

dbconfig.php

a guest
Feb 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2. class Database
  3. {  
  4.     private $host = "localhost";
  5.     private $db_name = "stechlk_cashmanage";
  6.     private $username = "seevlkco_newset";
  7.     private $password = "$=t?B84Sy4wO";
  8.     public $conn;
  9.      
  10.     public function dbConnection()
  11.     {
  12.      
  13.         $this->conn = null;    
  14.         try
  15.         {
  16.             $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  17.             $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  
  18.            
  19.         }
  20.         catch(PDOException $exception)
  21.         {
  22.             echo "Connection error: " . $exception->getMessage();
  23.         }
  24.          
  25.         return $this->conn;
  26.     }
  27. }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement