Advertisement
vencinachev

DBConnectPDO

Dec 14th, 2020
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 KB | None | 0 0
  1. <?php
  2. $host = 'localhost'; // 127.0.0.1
  3. $user = 'root';
  4. $pass = '';
  5. $port = "3306";
  6. $db   = 'school';
  7. $charset = 'utf8mb4';
  8.  
  9. $dsn = "mysql:host=$host;dbname=$db;charset=$charset;port=$port";
  10. try {
  11.      $pdo = new PDO($dsn, $user, $pass);
  12.      echo "Success";
  13. } catch (PDOException $e) {
  14.     die("Problem connecting to database");
  15. }
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement