September 17th, 2003, 08:18 PM
Can't get Postgres to connect with pg_connect()
I installed postgresql on my windows box and I'm trying to get it to connect with PHP.
here is where I'm at:
its installed properly - I created a db and tables using pgsql command line scripts, that works fine.
I un commented out the semi-colon ; in the php.ini file for the pgsql.dll extension
I restarted apache but I keep getting the following msg:
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: could not connect to server: No connection could be made because the target machine actively refused it. (0x0000274D) Is the server running on host webdev and accepting TCP/IP connections on port 5432? . in c:\www\pgsql\test.php on line 2
anyone have any thoughts on what it could be? I haven't been able to find anything on it
$db_handle = pg_connect("host=webdev dbname=test user=jim password=test") or die("Couldn't Connect: ".pg_last_error());
September 18th, 2003, 09:14 AM
postmaster has to be running with TCP/IP socket connections enabled. You can check what its startup options were with pg_ctl status I think, or you can un-comment that option in the postgresql.conf file now I don't know if this is all the same stuff in windows but I would imagine. I'd actually try to convince you to make your machine a dual boot with some distro of Linux so you can use postgres and related utilities more easily, but I suppose it is a matter of personal preference.
Also, at least with linux/unix you have to have configured php to --enable-pgsql or --with-pgsql to be allowed to use those functions. That doesn't seem to be the problem since the function at least returned with that error state.
September 19th, 2003, 02:28 PM
turned out to be a problem with the pg_hba.conf file
changed the host line and now I can connect just dandily