Advertisement
Guest User

Untitled

a guest
Jul 6th, 2021
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. <?php
  2. require_once 'config.php';
  3.  
  4. function connect($host, $db, $user, $password) {
  5. $dsn = "mysql:host=$host;dbname=$db;charset=UTF8";
  6.  
  7. try {
  8. $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
  9.  
  10. return new PDO($dsn, $user, $password, $options);
  11. } catch (PDOException $e) {
  12. die($e->getMessage());
  13. }
  14. }
  15.  
  16. return connect($host, $db, $user, $password);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement