title: How to connect to heroku postgres database?
body: <p>I'm trying to connect to postgres databse on heroku but it doesn't work for me.</p>
  
  <p>This is the code in index.php</p>
  
  <pre><code>&lt;?php
  $host = "my host";
  $dbname = "my database name";
  $user = "my username";
  $password = "my password";
  $port = "5432";
  
  $dsn = "pgsql:host=$host;dbname=$dbname;user=$user;port=$port;password=$password";
  
  $db = new PDO($dsn);
  
  if($db){
    echo "Connected &lt;br /&gt;".$db;
  }else {
    echo "Not connected";
  }
   ?&gt;
  </code></pre>
  
  <p>But nothing appear on the screen it should print not connected if the credentials are wrong.</p>
  
  <p>Help Please</p>
  
  <p>Thanks all</p>