Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. class Database{
  3. private $host = "localhost";
  4. private $db_name = "id1566013_practice";
  5. private $db_username = "id1566013_loginsystem";
  6. private $db_password = "063558531";
  7. private $conn;
  8.  
  9. // get the database connection.
  10. public function getConnection(){
  11. $this->conn = null;
  12.  
  13. try{
  14. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->db_username, $this->db_password);
  15. $this->conn->exec("set names utf8");
  16. }catch(PDOException $exception){
  17. echo "Connection error: " . $exception->getMessage();
  18. }
  19. return $this->conn;
  20. }
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement