Advertisement
rsamhollyer

PDO Connection

May 8th, 2022 (edited)
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. try {
  2.      $pdo = new PDO('mysql:dbname=mytodos;host=127.0.0.1;port=33060', 'root', 'password');
  3.   // $pdo = new PDO('mysql:dbname=mytodos;host=mysql;port=33060', 'root', 'password');
  4.   // $pdo = new PDO('mysql:host=0.0.0.0;dbname=mytodos', 'root', 'password');
  5.   // $pdo = new PDO('mysql:dbname=mytodos;host=mysql_test;port=33060', 'root', 'password');
  6.   // $pdo = new PDO('mysql:host=localhost;dbname=mytodos', 'root', 'password')
  7.   // $pdo = new PDO('mysql:host=172.18.0.2;dbname=mytodos', 'root', 'password'); This was the container IP address
  8.  
  9.     return $pdo;
  10. } catch (PDOException $e) {
  11.     die('Could not connect to the database:<br/>' . $e->getMessage());
  12. }
  13.  
  14. require 'views/index.view.php';
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement