php + postgresql pg_connect problem

From: John Taber <jtaber(at)johntaber(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: php + postgresql pg_connect problem
Date: 2005-12-13 20:34:50
Message-ID: 439F306A.4000801@johntaber.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am having trouble connecting php(5.1.1) and postgresql(8.1) running on
Ubuntu Breezy. Both run fine separately. I created a user (tempuser) and
a database (tempdb). If I run psql -l it shows the database "tempdb"
with the username "tempuser". But I get the following error using
pg_connect:

Warning: pg_connect() [function.pg-connect]: Unable to connect to
PostgreSQL server: FATAL: Ident authentication failed for user
"tempuser" in /var/www/db_connect.php on line 14

The line 14 is the pg_connect statement:
$dbname = "tempdb";
$user = "tempuser";
$pass = "";
$dbstr = "dbname=" . $dbname;
$dbstr .= " user=" . $user;
//$dbstr .= " password=" . $pass;
return(pg_connect($dbstr));

Now I did not create a password when I created the user and in
pg_connect just use the dbname and username values - is that a problem?
thanks.
ps: I tried it with the password value but that failed with same error.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2005-12-13 20:37:27 Re: pg_autovacuum
Previous Message David Rysdam 2005-12-13 20:12:26 "incomplete startup packet" on SGI