Guest User

Untitled

a guest
Apr 8th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. class DBConnect {
  4.  
  5. public function connect() {
  6.  
  7. // credentials
  8. $host = "host";
  9. $database = "database";
  10. $username = "username";
  11. $password = 'password';
  12. $charset = 'utf8mb4';
  13.  
  14. // connection and error handling
  15. try {
  16. $dbc = new PDO("mysql:host=$host; dbname=$database; charset=$charset", $username, $password);
  17. } catch( PDOException $error ) {
  18. die("ERROR: " . $error->getMessage());
  19. }
  20.  
  21. }
  22.  
  23. }
  24.  
  25. require "php/dbc.php";
  26.  
  27. $dbc = new DBConnect();
  28. $dbc->connect();
Add Comment
Please, Sign In to add comment