Page 1 of 1

pg_connect cannot connect to pgsql db

Posted: Tue Nov 12, 2002 11:22 pm
by soshea
being new to php and pgsql i was hoping somone could help with this:
utilizing the string:
pg_connect("dbname=test1");
i get the error saying that user apache cannot connect to database
changing it to:
pg_connect("dbname=test1 user=user1")
i get the error saying that authentication failed for user user1
but the kicker is that i can su - user1 from root and psql just fine to the databases and do any query.
any advice or ideas on where to go next?
thanx
sean

Posted: Wed Nov 13, 2002 3:17 am
by volka
when using su you probably provide a password for that account but you don't in your connect string.
http://www.php.net/manual/en/function.pg-connect.php
$dbconn3 = pg_connect ("host=sheep port=5432 dbname=mary user=lamb password=foo");

Posted: Wed Nov 13, 2002 10:10 am
by soshea
i guess i should have added that. i tested it and no luck. i did find the possible problem i need to enter in pg_hba.conf to allow the internet users.
any idea on how to allow any ipaddress to have access? since i am utilizing php, would i actually have the ip address of my server be added since the scripts are run from there?
thanx for the reply!!
sean