Jump to content

Problem connecting to postgres database using php


veenasv

Recommended Posts

I have installed Mandrake8.2 . And decided to use postgresql with php for web page development. and the webserver is apache. Mandrake is bundled with postgres, php. So, am using the same. I wrote a simple program to conenct to the postgres database using php. But it gives following error:

 

Warning: Unable to connect to PostgreSQL server: FATAL 1: No pg_hba.conf entry for host 127.0.0.1, user apache, database x6a in /var/www/html/veena/test.php on line 2

 

Couldn\'t connect

 

My program goes like this:

<?php

$connection = pg_Connect( \"host=localhost dbname=x6a\" )

or die(\"Couldn\'t connect\");

$result = pg_exec($connection, \"SELECT * FROM addresses;\")

or die(\"couldn\'t execute\");

?>

 

I have granted all previleges to user apache in my addresses table in x6a database. I also have entry in pg_hba.conf as:

 

local all trust

localhost all 127.0.0.1 255.255.255.255 trust

 

Any help will be appreciated.

i don\'t think many of us forum-goers are familiar with postgre...

 

here is the manual entry for pg_connect — sift through the user contributed notes and see if anything helps.

 

http://www.php.net/manual/en/function.pg-connect.php

 

also, when all else fails, try google.

 

does this help any?

 

http://www.vmlinuz.ca/archives/expert/2002...7/msg00910.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.