pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kitty Yuen <kitty3a@gmail.com>
To: Matthew Terenzio <matt@jobsforge.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Problems in connecting to postgreSQL using PHP
Date: Tue, 13 Mar 2007 10:27:13 +0800
Message-ID: <b3efba5a0703121927p7247f399ueadc006d9a78a88f@mail.gmail.com> (raw)
In-Reply-To: <f22361d85ef58b122d12731d3888a589@jobsforge.com>
References: <b3efba5a0703112125s23b7eac1u60639be8ac06def4@mail.gmail.com>
	<f22361d85ef58b122d12731d3888a589@jobsforge.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='function.pg-connect'>function.pg-connect</a>]: 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 &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='function.pg-last-error'>function.pg-last-error</a>]: No PostgreSQL
link opened yet in /var/www/html/try.php on line 4

PHP Code:


<?php

// Connecting, selecting database

$dbconn = pg_connect("dbname=test user=postgres")

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



// Performing SQL query

$query = 'SELECT * FROM haha';

$result = pg_query($query) or die('Query failed: ' . pg_last_error());



// Printing results in HTML

echo "<table>\n";

while ($line = 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          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 = 'localhost'             # what IP address(es) to listen
on;

                                        # comma-separated list of addresses;

                                        # defaults to 'localhost', '*' = all

port = 5432

max_connections = 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 = 2

unix_socket_directory = ''

unix_socket_group = ''

unix_socket_permissions = 0777              # octal
bonjour_name = ''                     # defaults to the computer name

Thanks a lot,
Kitty3A






On 3/12/07, Matthew Terenzio <matt@jobsforge.com> 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 access
> > the database through SSH and I can connect with it.
> >
> > Would you please offer any suggestions or solutions?
> >
> > Manythanks,
> > Kitty3A
>
>

view thread (10+ messages)  latest in thread

Message-ID: <b3efba5a0703121927p7247f399ueadc006d9a78a88f@mail.gmail.com>
Permalink:  ../b3efba5a0703121927p7247f399ueadc006d9a78a88f@mail.gmail.com/
Also on:    postgresql.org/message-id/b3efba5a0703121927p7247f399ueadc006d9a78a88f@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: kitty3a@gmail.com, matt@jobsforge.com
  Subject: Re: Problems in connecting to postgreSQL using PHP
  In-Reply-To: <b3efba5a0703121927p7247f399ueadc006d9a78a88f@mail.gmail.com>
  References: <b3efba5a0703112125s23b7eac1u60639be8ac06def4@mail.gmail.com> <f22361d85ef58b122d12731d3888a589@jobsforge.com> <b3efba5a0703121927p7247f399ueadc006d9a78a88f@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox