PostgreSQL connection Fails

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Love_Daddy
Forum Commoner
Posts: 61
Joined: Wed Jul 10, 2002 6:55 am
Location: South Africa
Contact:

PostgreSQL connection Fails

Post by Love_Daddy »

Hi All,

I'm battling to connect to my Database using the ff method::

<?
$user="romeom";
$dbname="employees";

$conn=pg_connect("user=$user dbname=$dbname");
if (!$conn) {
echo "No Connection";
} else {
echo "Connection Established";
}
?>

When I run in konsole using php <filename.php> it says Connection Established,
But in http://localhost/test.php, it does not establish the connection.
The error message is:
Unable to connect to Postgresql server:FATAL 1: IDENT authentication failed for user "romeom" in
<b>/var/www/html/test.php</b> on line 4
Connection Failed.

What am I doing wrong?undefinedundefined
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post by 9902468 »

Postgre allows connections from your computer, but not from host localhost. Edit your something_hba.conf file.
Post Reply