Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2. $servername = "db"; //I'm not sure what I've to put here /service name(db) or IP of the container?
  3. $username = "php";
  4. $password = "php";
  5.  
  6. try {
  7. $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
  8. // set the PDO error mode to exception
  9. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  10. echo "Connected successfully";
  11. }
  12. catch(PDOException $e)
  13. {
  14. echo "Connection failed: " . $e->getMessage();
  15. }
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement