Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot connect from php 1

Status
Not open for further replies.

warby1212

Programmer
Jun 9, 2003
183
AU
Hi,

I can't connect to Postgresql. The installation is "straight of the box" on Red Hat 8.2. PHP is runing ok.
I get this message in browser:

Warning: Unable to connect to PostgreSQL server: connectDBStart() -- connect() failed: Connection refused Is the postmaster running (with -i) at 'localhost' and accepting connections on TCP/IP port 5432? in /var/ on line 15
Could not open connection to database server

with this in the php file:
$host = "localhost";
$user = "postgres";
$pass = "postgres";
$db = "stedb";

$connection = pg_connect ("host=$host dbname=$db user=$user");

When I enter: postmaster -i -D /var/lib/psql/data
I get the message: ...postmaster.pid already exists

Can anyone suggest hwere I can look to get through?

Cheers stephen
 
Hi stephen,

Try deleting the postmaster.pid file. Then postgres should start.

Regards,

LelandJ

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
if it is localhost and it uses UNIX sockets (this is default for postgres)

try without host i.e.

$connection = pg_connect ("dbname=$db user=$user password=$pass");

if pg_hba.conf is configured with
local all all trust

then password is not needed

you can enable tcp usage in postgresql.conf, then you can connect with host=localhost
 
Thanks for your replies all. I dropped "host" out of pg_connect and it is now returning true :)

but while I have your attention, my pg_query is producing the error:

"Call to undefined function: pg_query()"

A quick google around produced suggestions that Postgresql was not built into PHP. But if both came precompiled in the Red Hat release, wouldn't they be compatible and secondly does a successful pg_connect() prove compatability?

Thanks again
Stephen
 
if the php is old version the function is pg_exec()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top