trouble with pg_connect

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I'm having some troubles getting pg_connect() to connect over UNIX
domain sockets.  Something that really confuses me is the error string
being served up by apache.  It says it was unable to connect to
database xxxx.  However, the characters are gibberrish.  At first I
thought that my problem was that I forgot to give the user name also
(seeing there was no apache user in postgresql).  However that wasn't
it.  To make sure though, I added an apache username to the postgresql

Currently, my pg_connect looks like this:

$dbconn = pg_connect("dbname=mydb user=andy");

I have checked the pg_hba.conf file, but that shouldn't be it as I can
connect via psql over UNIX domain.  However, given my current
predicament, I'd like any and all suggestions.


Re: trouble with pg_connect writes:

Quoted text here. Click to load it

Never had this problem.

Food for thought; are you still running the same version of Postgres
that your PHP module was built against?

Jerry Sievers   305 854-3001 (home)     WWW ECommerce Consultant
                305 321-1144 (mobile /

Re: trouble with pg_connect wrote:
Quoted text here. Click to load it

The fact that you have gibberish characters in the error string is a red
herring. I saw that when connecting over TCP/IP using "host=localhost". I
took that host parameter out so it used UNIX sockets and it continued to
give error messages like you're getting. I was as bewildered as you are.

I never did work it out. PostgreSQL security seems horribly complex. I got
around the problem by turning the security off. I deleted all the default
entries from /var/lib/pgsql/data/pg_hba.conf and added this line instead:

local  all  all  trust

which at least allowed me to get on with my project. I can't recommend it as
a sensible solution though. Guys like us need to learn how to do this stuff

The email address used to post is a spam pit. Contact me at : <a
href=" /">Derek Fountain</a>

Re: trouble with pg_connect wrote:
Quoted text here. Click to load it
is postgres support compiled/loaded into your php. Check phpinfo()...


Site Timeline