Help in connecting to a database with PHP

Help in connecting to a database with PHP

am 27.05.2002 08:07:20 von mmcgillick

This is a multi-part message in MIME format.

------=_NextPart_000_0006_01C20523.3EC00100
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi:



I'm trying to learn how to set up a .php file to connect to my
PostgreSQL database. From the command line, I can connect, open and work
in the database on my machine. However, if I create a .php page with the
following information:



$db = pg_connect("dbname=baseball user=postgres");



I get the following error message:



Warning: Unable to connect to PostgreSQL server: FATAL 1: IDENT
authentication failed for user "postgres" in /var/www/html/baseball.php
on line 10.



I'm running a stock Red Hat Linux 7.3 machine with PostgreSQL version
7.2. I have verified that from the command line, I can switch to the
user postgres and connect to the database with no problems. I can view
data, add and delete records, etc.



I'd appreciate some help in trying to track down what I'm doing wrong.
I've spent the past few days looking at documentation from various web
sites, and nothing seems to jump out as the culprit.



- Michael


------=_NextPart_000_0006_01C20523.3EC00100
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

















0.0pt;
font-family:Arial'>Hi:



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>I’m trying to learn how to set up a .php file to
connect to my PostgreSQL database. From the command line, I can connect, op=
en
and work in the database on my machine. However, if I create a .php page wi=
th
the following information:



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>   $db =3D pg_connect(“dbname=3Dbaseball
user=3Dpostgres”);



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>I get the following error message:



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>   Warning=
:
Unable to connect to PostgreSQL server: FATAL 1: IDENT authentication failed
for user “postgres” in /var/www/html/baseball.php on line 10. span>



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>I’m running a stock Red Hat Linux 7.3 machine with
PostgreSQL version 7.2. I have verified that from the command line, I can s=
witch
to the user postgres and connect to the database with no problems. I can vi=
ew
data, add and delete records, etc.



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>I’d appreciate some help in trying to track down w=
hat
I’m doing wrong. I’ve spent the past few days looking at
documentation from various web sites, and nothing seems to jump out as the
culprit.



0.0pt;
font-family:Arial'> 



0.0pt;
font-family:Arial'>- Michael









------=_NextPart_000_0006_01C20523.3EC00100--

Re: Help in connecting to a database with PHP

am 27.05.2002 10:55:52 von Ludwig Lim

Hi:

--- "Michael J. McGillick"
wrote:
> Hi:
>
>
>
> I'm trying to learn how to set up a .php file to
> connect to my
> PostgreSQL database. From the command line, I can
> connect, open and work
> in the database on my machine. However, if I create
> a .php page with the
> following information:
>
>
>
> $db = pg_connect("dbname=baseball
> user=postgres");
>
>
>
> I get the following error message:
>
>
>
> Warning: Unable to connect to PostgreSQL server:
> FATAL 1: IDENT
> authentication failed for user "postgres" in
> /var/www/html/baseball.php
> on line 10.

Try checking the file "pg_hba.conf" ( Usually in
/usr/local/pgsql/data). It seems that your connection
requires a password. try to set the "auth_type" to
"trust" in "pg_hba.conf" to skip password check or use
"pg_connect(dbname=baseball user=postgres
password=
Hope that helps.

ludwig.

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Help in connecting to a database with PHP

am 27.05.2002 11:30:36 von Eckhard Hoeffner

* Michael J. McGillick [27 05 02 08:07]:

>Hi:
>
>=20
>
>I'm trying to learn how to set up a .php file to connect to my
>PostgreSQL database. From the command line, I can connect, open and work
>in the database on my machine. However, if I create a .php page with the
>following information:
>
>=20
>
> $db =3D pg_connect("dbname=3Dbaseball user=3Dpostgres");
>
>=20
>
>I get the following error message:

If you are accessing the database via a web server, you should allow
TCP/IP connections. (postmaster -i)

> Warning: Unable to connect to PostgreSQL server: FATAL 1: IDENT
>authentication failed for user "postgres" in /var/www/html/baseball.php
>on line 10.
This looks like a socket connection, not TCP/IP.=20
>=20
>
>I'm running a stock Red Hat Linux 7.3 machine with PostgreSQL version
>7.2. I have verified that from the command line, I can switch to the
>user postgres and connect to the database with no problems. I can view
>data, add and delete records, etc.
>
>=20
>
>I'd appreciate some help in trying to track down what I'm doing wrong.
>I've spent the past few days looking at documentation from various web
>sites, and nothing seems to jump out as the culprit.
>
>=20
>
>- Michael
>

--=20
--//--\\--
Eckhard Hoeffner
e-hoeffner@fifoost.org
Tal 44=20
D-80331 München

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster