I'm trying to connect to postgres databse on heroku but it doesn't work for me.
This is the code in index.php
<?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 <br />".$db;
}else {
echo "Not connected";
}
?>
But nothing appear on the screen it should print not connected if the credentials are wrong.
Help Please
Thanks all