From: | Bob Hartung <rwhart(at)mchsi(dot)com> |
---|---|
To: | Postgres-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [PHP] works at command line but not in apache |
Date: | 2007-03-18 00:59:03 |
Message-ID: | 45FC8ED7.5080200@mchsi.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks, but I have these changes in and it still will not connect:
file: pg_hba.conf:
# IPv4 local connections:
host all all 127.0.0.1/32 ident sameuser
postgrsql.conf:
listen_addresses = 'localhost'
port = 5432
It is my understanding that the current version 8.1+ now uses the
generalized 'listen_addresses' in postgresql.conf instead of any tcp* =
'true' statements in this file.
I also am assuming that the postgresql.conf file being read is that in
the /var/lib/pgsql/data directory.
I am connecting to localhost, need to make sure I can configure for
tcpip, and am trying to login as a local user with a user account on the
machine.
Other ideas? I am not having much luck finding more in the docs.
TIA
Bob
Tijnema ! wrote:
> On 3/17/07, rwhartung <rwhartung(at)rgimaging(dot)com> wrote:
>> Hi,
>> I have this short php script: [op;ening <?php and closing ?> removed.
>>
>>
>> $db = pg_connect('dbname=bpsimple user=minitwr password=RWHart') ;
>
>> print $db . "<br />" . "\n" ;
>> if ($db)
>> {
>> print 'Connection attempt succeeded.' . "<br />" . "\n" ;
>> } else
>> {
>> print 'Connection attempt failed.'. "<br />" . "\n" ;
>> }
>>
>> $query = 'SELECT fname, lname FROM customer' ;
>> $result = pg_query($db, $query) ;
>> while($myrow = pg_fetch_assoc($result) )
>> {
>> print $myrow['fname'] . " " . $myrow['lname'] . "\n" ;
>> }
>>
>> This works fine as a PHP script from the command line, but wrapped up in
>> <html> </html> tags it refuses to connect with the database from within
>> apache. All connections are local host. PHP otherwise works fine on
>> the apache server and the code is identical on both the CL script and
>> the test.php web page. Ideas? Where to start looking?
>>
>> TIA
>>
>> Bob
>
> One of the comments in the PHP Manual says this:
>
> If you use pg_connect('host=localhost port=5432 user=my_username
> password=my_password dbname=my_dbname') and you get the following
> error:
> "Warning: pg_connect(): Unable to connect to PostgreSQL server: could
> not connect to server: Connection refused Is the server running on
> host localhost and accepting TCP/IP connections on port 5432?"
> then you should try to leave the host= and port= parts out of the
> connection string. This sounds strange, but this is an "option" of
> Postgre. If you have not activated the TCP/IP port in postgresql.conf
> then postgresql doesn't accept any incoming requests from an TCP/IP
> port. If you use host= in your connection string you are going to
> connect to Postgre via TCP/IP, so that's not going to work. If you
> leave the host= part out of your connection string you connect to
> Postgre via the Unix domain sockets, which is faster and more secure,
> but you can't connect with the database via any other PC as the
> localhost.
>
> I think that's what your problem is also, but not sure about it.
> (using MySQL mostly)
>
> Tijnema
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Reece Hart | 2007-03-18 01:14:17 | Re: Postgres Database size |
Previous Message | Christian Schröder | 2007-03-18 00:07:11 | Re: issue with SELECT settval(..); |