Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 07C969FB25F for ; Tue, 13 Mar 2007 22:33:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 25776-05 for ; Tue, 13 Mar 2007 22:33:39 -0300 (ADT) X-Greylist: delayed 00:06:58.251694 by SQLgrey-1.7.4 Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.183]) by postgresql.org (Postfix) with ESMTP id 95AFF9FB25D for ; Tue, 13 Mar 2007 22:33:49 -0300 (ADT) Received: by ik-out-1112.google.com with SMTP id c21so4944ika for ; Tue, 13 Mar 2007 18:33:47 -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=FNfnP81V8tcwIxnx62YrRUlFSnEuZFSIz2kLTnbeAdzkVBD8NOENW1iL7HJTqoyGQy//0BJPmOn4jUr+wCaHpRLpysoKt4ui5Zelqn5o1bO19QFa3NOUCW1uTXsaMV6XdGM7N8tTcE57Mm2xad1m5go97n9gd9DnxoZgHZESX/M= 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=cKMNRUTU/FnUZFdfPbRBS33N8WoJEExgPc7uzH/cQSS/KjHs2xyWtM5HdCid9odWc2v2PlVHG+p2oB/bPjJEyFcEiiCYS4i0Uzr7/9GnXf4XxDjEVX/9EYLt6O16cW7OMrxpsQekavWA8oWdWRvLGQmPNEuppVXlDs1TpmDaLiw= Received: by 10.115.58.1 with SMTP id l1mr2667441wak.1173835607330; Tue, 13 Mar 2007 18:26:47 -0700 (PDT) Received: by 10.114.152.10 with HTTP; Tue, 13 Mar 2007 18:26:47 -0700 (PDT) Message-ID: Date: Wed, 14 Mar 2007 09:26:47 +0800 From: "Kitty Yuen" To: "=?ISO-8859-1?Q?Valent=EDn_Orfila?=" Subject: Re: Problems in connecting to postgreSQL using PHP Cc: "Matthew Terenzio" , pgsql-php@postgresql.org In-Reply-To: <6b8c0db0703130615m15eef49fj59fa34ab670c5fe9@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_39759_4138752.1173835607267" References: <6b8c0db0703130615m15eef49fj59fa34ab670c5fe9@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/44 X-Sequence-Number: 3756 ------=_Part_39759_4138752.1173835607267 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dear Valent=EDn, 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 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 t= he > ";" 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 I0= m > 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.php = 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 pe= r > > > > > > # connection slot, plus lock space (see max_locks_per_transaction). Yo= u > > > > # 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 name > > > > 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 have > > > > 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 acces= s > > > > 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 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_39759_4138752.1173835607267 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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

O= n 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 Pla= nificaci=F3n y Desarrollo de la Rep=FAblica 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
*************************= **************************************************


------=_Part_39759_4138752.1173835607267--