I need to connect to some PostgreSQL server providing some credentials, and print a list of available databases on that host for a given user.
I am trying:
$connection = pg_connect("host=localhost user=testuser password=123 connect_timeout=5");
And I get:
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: FATAL: database "testuser" does not exist in /var/www/test.php on line 56
I thought this must be possible because phpPgAdmin does it, but I looked at phpPpAdmin sources and found that they connect to a database named template1.
Is there a way to connect without specifying any database?