Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 4CCE09FB2AC for ; Wed, 14 Mar 2007 18:26:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 23855-06 for ; Wed, 14 Mar 2007 18:26:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.188]) by postgresql.org (Postfix) with ESMTP id 70A399FB368 for ; Wed, 14 Mar 2007 18:26:34 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id x4so417703nfb for ; Wed, 14 Mar 2007 14:26:33 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=lQ/Km5Tf0STFd7wncvuoNHXNmB5jJP8CE17Wj3pvTRYbE/g09p5S2ghRrMvjAOfI9j5rxDUnR/XIKkGD8KHqG7B+JhGWNSjHI4QXwPeUYJv+Z7LdoCDJ0i2MD7QkJkdgHK8okm1OXz/VA2uzoKE7oAFz2Kv+AhiI1CxSVBFFRz8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=EqigUaORfvNBDYS6TMMS3sqDoj8Bd1LxT4V00XqDwY1QuuDxRXR2kkRZZG0K8xyp90zepvEPT79Nq2D1e1C/nxmW0s6IA47lI0Fj0oDJyR7xeiiMzARl1qaY3MipdqJjZy9F/65Y/6b9iyssDbKBN23P2NAiWgTODb2W+d7y+sQ= Received: by 10.78.140.17 with SMTP id n17mr30068hud.1173895152629; Wed, 14 Mar 2007 10:59:12 -0700 (PDT) Received: by 10.78.160.6 with HTTP; Wed, 14 Mar 2007 10:59:12 -0700 (PDT) Message-ID: <6b8c0db0703141059w1c2aba32gfe7ebc310208279e@mail.gmail.com> Date: Wed, 14 Mar 2007 13:59:12 -0400 From: "=?ISO-8859-1?Q?Valent=EDn_Orfila?=" To: "Kitty Yuen" Subject: Re: Problems in connecting to postgreSQL using PHP Cc: "Matthew Terenzio" , pgsql-php@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_33402_18509013.1173895152489" References: <6b8c0db0703130615m15eef49fj59fa34ab670c5fe9@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/46 X-Sequence-Number: 3758 ------=_Part_33402_18509013.1173895152489 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I already told you all I thought, but... Below is the local config in my pg_hba and i just see you have one line mor= e than me, do you use Unix? if not, so erase that line and try again # TYPE DATABASE USER CIDR-ADDRESS METHOD # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: localhost all all ::1/128 trust 2007/3/13, Kitty Yuen : > > Dear Valent=EDn, > > I think I have already enabled the extension and found the extension in m= y > pgsql.ini file in php.d folder. However, I still cannot connect to the > database. I guess I have something to be config in the PostgreSQL. Do you > have any ideas? > > > Kitty3a > > On 3/13/07, Valent=EDn Orfila wrote: > > > > OK. Now you have to activate the library to connect PHP to PostgreSQL, > > this is in the php.ini file. In Windows 2000 it is in the following > > folders: C:\WINNT and in the PHP installation folder, in my case: > > C:\AppServ\php. Once you find this file you have to discomment this > > extension: extension=3Dphp_pgsql.dll, to do that you are going to erase= the > > ";" at the beggining of the line. > > > > Look for this file (php.ini) in your O.S. and configured it. If you are > > using Linux I guess it is in the etc/profile/php.config directory, but = I0m > > not sure. > > > > I'm attaching you my file: > > > > > > 2007/3/12, Kitty Yuen : > > > > > > Here are my error messages from PHP: > > > > > > > > > [Mon Mar 12 16:01:26 2007] [error] [client 127.0.0.1] PHP Warning: = pg_connect() > > > [function.pg-connect]: Unable to > > > connect to PostgreSQL server: could not connect to server: Permission > > > denied\n\tIs the server running locally and accepting\n\tconnections = on Unix > > > domain socket "/tmp/.s.PGSQL.5432"? in /var/www/html/try.ph= p on > > > line 3 > > > > > > [Mon Mar 12 16:01:26 2007] [error] [client 127.0.0.1] PHP Warning: = pg_last_error() > > > [function.pg-last-error]: No > > > PostgreSQL link opened yet in /var/www/html/try.php on line 4 > > > > > > PHP Code: > > > > > > > > > > > > > > // Connecting, selecting database > > > > > > $dbconn =3D pg_connect("dbname=3Dtest user=3Dpostgres") > > > > > > or die('Could not connect: ' . pg_last_error()); > > > > > > > > > > > > // Performing SQL query > > > > > > $query =3D 'SELECT * FROM haha'; > > > > > > $result =3D pg_query($query) or die('Query failed: ' . pg_last_error(= )); > > > > > > > > > > > > // Printing results in HTML > > > > > > echo "\n"; > > > > > > while ($line =3D pg_fetch_array($result, null, PGSQL_ASSOC)) { > > > > > > echo "\t\n"; > > > > > > foreach ($line as $col_value) { > > > > > > echo "\t\t\n"; > > > > > > } > > > > > > echo "\t\n"; > > > > > > } > > > > > > echo "
$col_value
\n"; > > > > > > > > > > > > // Free resultset > > > > > > pg_free_result($result); > > > > > > > > > > > > // Closing connection > > > > > > pg_close($dbconn); > > > > > > > > > > > > *pg_hba.cof* > > > > > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > > > > > > > > > > > # "local" is for Unix domain socket connections only > > > > > > local all all trust > > > > > > > > > > > > # IPv4 local connections: > > > > > > host all all 127.0.0.1/32 trust > > > > > > # IPv6 local connections: > > > > > > host all all ::1/128 trust > > > > > > *postgresql.conf* > > > > > > > > > > > > #--------------------------------------------------------------------= ------- > > > > > > # CONNECTIONS AND AUTHENTICATION > > > > > > > > > #--------------------------------------------------------------------= ------- > > > > > > > > > > > > # - Connection Settings - > > > > > > > > > > > > listen_addresses =3D 'localhost' # what IP address(es) to > > > listen on; > > > > > > # comma-separated list of > > > addresses; > > > > > > # defaults to 'localhost', '*= ' > > > =3D all > > > > > > port =3D 5432 > > > > > > max_connections =3D 100 > > > > > > # note: increasing max_connections costs ~400 bytes of shared memory > > > per > > > > > > # connection slot, plus lock space (see max_locks_per_transaction). > > > You > > > > > > # might also need to raise shared_buffers to support more connections= . > > > > > > superuser_reserved_connections =3D 2 > > > > > > unix_socket_directory =3D '' > > > > > > unix_socket_group =3D '' > > > > > > unix_socket_permissions =3D 0777 # octal > > > bonjour_name =3D '' # defaults to the computer na= me > > > > > > Thanks a lot, > > > Kitty3A > > > > > > > > > > > > > > > > > > > > > On 3/12/07, Matthew Terenzio wrote: > > > > > > > > Could you provide any PHP errors or the pg_hba.conf ? > > > > > > > > On Mar 12, 2007, at 12:25 AM, Kitty Yuen wrote: > > > > > > > > > Hi, > > > > > > > > > > I am trying to connect my postgreSQL with PHP in localhost. I hav= e > > > > > start up the server with -i flag (i.e. postmaster -D > > > > > /usr/local/pgsql/data -i &) and edit the pg_hba.conf. However, I > > > > still > > > > > cannot connect with the database. But, when I tried to remote > > > > access > > > > > the database through SSH and I can connect with it. > > > > > > > > > > Would you please offer any suggestions or solutions? > > > > > > > > > > Manythanks, > > > > > Kitty3A > > > > > > > > > > > > > > > > > -- > > > > ***********************************************************************= **** > > Ministerio de Planificaci=F3n y Desarrollo de la Rep=FAblica Bolivarian= a de > > Venezuela > > Direcci=F3n de Planes de Personal > > > > Jos=E9 Valent=EDn Orfila Brice=F1o > > Programador II > > > > Tel=E9fonos: Celular: (0416) 4131418 > > > > E-mail: valentinorfila@gmail.com > > valentinorfila@hotmail.com > > josevalentinorfila@yahoo.com > > > > Messenger: valentinorfila@hotmail.com > > > > Skype: valentinorfila > > valentinorfila@gmail.com > > ***********************************************************************= **** > > > > > > > --=20 *************************************************************************** Ministerio de Planificaci=F3n y Desarrollo de la Rep=FAblica Bolivariana de Venezuela Direcci=F3n de Planes de Personal Jos=E9 Valent=EDn Orfila Brice=F1o Programador II Tel=E9fonos: Celular: (0416) 4131418 E-mail: valentinorfila@gmail.com valentinorfila@hotmail.com josevalentinorfila@yahoo.com Messenger: valentinorfila@hotmail.com Skype: valentinorfila valentinorfila@gmail.com *************************************************************************** ------=_Part_33402_18509013.1173895152489 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I already told you all I thought, but...

Below is the local config i= n my pg_hba and i just see you have one line more than me, do you use Unix?= if not, so erase that line and try again

# TYPE  DATABASE = ;   USER        CIDR-ADDRESS&n= bsp;         METHOD

# IPv4 local connections:
host    all  =        all      = ;   127.0.0.1/32  &= nbsp;         trust

# IPv6 l= ocal connections:
localhost    all    = ;     all       &nbs= p; ::1/128           = ;    trust




2007/3/13, Kitty Yuen = <kitty3a@gmail.com>:<= blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 2= 04, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Dear Valent=EDn,<= br>
I think I have already enabled = the extension and found the extension in my pgsql.ini file in php.d folder.= However, I still cannot connect to the database. I guess I have something = to be config in the PostgreSQL. Do you have any ideas?


Kitty3a

On 3/13/07, Valent=EDn Orfila < valentinorfila@gmail.com> wrote:
OK. Now you have = to activate the library to connect PHP to PostgreSQL, this is in the php.in= i file. In Windows 2000 it is in the following folders: C:\WINNT and in the = PHP installation folder, in my case: C:\AppServ\php. Once you find this fil= e you have to discomment this extension: extension=3Dphp_pgsql.dll, to do t= hat you are going to erase the ";" at the beggining of the line.

Look for this file (php.ini) in your O.S. and configured it. If you= are using Linux I guess it is in the etc/profile/php.config directory, but= I0m not sure.

I'm attaching you my file:


2007/3/12, Kitty Yuen <kitty3a@gmai= l.com>:
Here are my error messages from PHP:
 

[Mon Mar 12 16:01:26 2007] [error] [client 127.0.0.1] PHP Warning:   pg_connect() [<a href=3D'function.pg-connect'>f= unction.pg-connect</a>]: Unable to connect to PostgreSQL server: coul= d not connect to server: Permission denied\n\tIs the server running locally= and accepting\n\tconnections on Unix domain socket &quot;/tmp/.s.PGSQL= .5432&quot;? in /var/www/html/try.php on line 3

[Mon Mar 12 16:01:26 2007] [error] [client 127.0.0.1] PHP Warning:   pg_last_error() [<a href=3D'function.pg-last-error'= ;>function.pg-last-error</a>]: No PostgreSQL link opened yet in /v= ar/www/html/try.php on line 4

 
PHP Code:
 

<?php

// Connecting, selecting database

$dbconn =3D pg_connect("dbname=3Dtest user=3Dpostgres"= )

   or die('Could not connect: ' .= pg_last_error());

 

// Performing SQL query

$query =3D 'SELECT * FROM haha';

$result =3D pg_query($query) or die('Query failed: ' . p= g_last_error());

 

// Printing results in HTML

echo "<table>\n";

while ($line =3D pg_fetch_array($result, null, PGSQL_ASSOC)) {

   echo "\t<tr>\n";

   foreach ($line as $col_value) {=

       echo "\t\= t<td>$col_value</td>\n";

   }

   echo "\t</tr>\n";

}

echo "</table>\n";

 

// Free resultset

pg_free_result($result);

 

// Closing connection

pg_close($dbconn);

 

pg_hba.cof

# TYPE  DATABASE    USER         CIDR-ADDRESS &= nbsp;        METHOD=

 

# "local" is for Unix domain socket connections only

local   all    =      all             &nb= sp;            =       trust

 

# IPv4 local connections:

host    all   &= nbsp;     all          127.0.0.1/32      &nbs= p;   trust

# IPv6 local connections:

host    all   &= nbsp;     all          ::1/128 =             &nb= sp; trust

 
postgresql.conf
 

#---------------------------------------------------------------= ------------

# CONNECTIONS AND AUTHENTICATION

#---------------------------------------------------------------= ------------

 

# - Connection Settings -

 

listen_addresses =3D 'localhost'   =           # what IP add= ress(es) to listen on;=20

         &nbs= p;            &= nbsp;           &nbs= p;     # comma-separated list of addresses;

         &nbs= p;            &= nbsp;           &nbs= p;     # defaults to 'localhost', '*= ' =3D all

port =3D 5432

max_connections =3D 100

# note: increasing max_connections costs ~400 bytes of shared me= mory per

# connection slot, plus lock space (see max_locks_per_transactio= n).  You

# might also need to raise shared_buffers to support more connec= tions.

superuser_reserved_connections =3D 2

unix_socket_directory =3D ''

unix_socket_group =3D ''

unix_socket_permissions =3D 0777    &n= bsp;         # octal<= /span>

bonjour_name =3D ''     = ;            &n= bsp;   # defaults to the computer name
 
Thanks a lot,
Kitty3A
 
 
 
 

 
On 3/12/07, = Matthew Terenzio <matt@jobsfor= ge.com > wrote:
Could you provide= any PHP errors or the pg_hba.conf ?

On Mar 12, 2007, at 12:25 AM, K= itty Yuen wrote:

> Hi,
>
> I am trying to connect my postgreSQL with= PHP in localhost. I have
> start up the server with -i flag (i.e. po= stmaster -D
> /usr/local/pgsql/data -i &) and edit the pg_hba.con= f. However, I still
> cannot connect with the database. But, when I tried to remote acce= ss
> the database through SSH and I can connect with it.
>
= > Would you please offer any suggestions or solutions?
>
> Manythanks,
> Kitty3A





--
*************************************************************= **************
Ministerio de Planificaci=F3n y Desarrollo de la Rep=FAbl= ica Bolivariana de Venezuela=20
Direcci=F3n de Planes de Personal

Jos=E9 Valent=EDn Orfila Brice= =F1o
Programador II

Tel=E9fonos: Celular: (0416) 4131418

= E-mail: valentinorfila@gmail.com
           valentinorfila@hotmail.com
 &nb= sp;         josevalentinorfila@yahoo.com

Messenger: valentinorfila@hotmail.com

Skype: valentinorfila
  =          valentinorfila@gmail.com
*************************= **************************************************





--
**********= *****************************************************************
Minist= erio de Planificaci=F3n y Desarrollo de la Rep=FAblica Bolivariana de Venez= uela=20
Direcci=F3n de Planes de Personal

Jos=E9 Valent=EDn Orfila Brice= =F1o
Programador II

Tel=E9fonos: Celular: (0416) 4131418

= E-mail: valentinorfila@gmail.co= m
           valentinorfila@hotmail.com
 &nb= sp;         josevalentinorfila@yahoo.com

Messenger:= valentinorfila@hotmail.com

Skype: valentinorfila
  =          valentinorfila@gmail.com
*************************= ************************************************** ------=_Part_33402_18509013.1173895152489--