pg_connect cannot connect to pgsql db

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
soshea
Forum Commoner
Posts: 31
Joined: Tue Nov 12, 2002 11:22 pm
Location: Idaho
Contact:

pg_connect cannot connect to pgsql db

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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");
User avatar
soshea
Forum Commoner
Posts: 31
Joined: Tue Nov 12, 2002 11:22 pm
Location: Idaho
Contact:

Post 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
Post Reply