Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //I've tried the commented section and it also doesn't work when deployed
- //$dsn = "pgsql:host=127.0.0.1;port=5432;dbname=postgres";
- $dsn = "pgsql:host=/cloudsql/portal-212515:us-central1:myinstance;port=5432;dbname=postgres";
- $username = "postgres";
- $password = "mypassword";
- try {
- $conn = new PDO($dsn, $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
Add Comment
Please, Sign In to add comment