Guest User

Untitled

a guest
Oct 9th, 2018
118
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. //I've tried the commented section and it also doesn't work when deployed
  4. //$dsn = "pgsql:host=127.0.0.1;port=5432;dbname=postgres";
  5. $dsn = "pgsql:host=/cloudsql/portal-212515:us-central1:myinstance;port=5432;dbname=postgres";
  6.  
  7. $username = "postgres";
  8. $password = "mypassword";
  9.  
  10. try {
  11. $conn = new PDO($dsn, $username, $password);
  12. // set the PDO error mode to exception
  13. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  14. echo "Connected successfully";
  15. }
  16. catch(PDOException $e)
  17. {
  18. echo "Connection failed: " . $e->getMessage();
  19. }
  20. ?>
Add Comment
Please, Sign In to add comment