Can you log into the PostgreSQL server from the console or command line?
Are you sure you are using the right username, password or host?

-----Original Message-----
From: Thomas Bonham [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 26, 2005 8:03 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: PostgreSQL error with PHP

I rewrote the code. This is the code and errors.
This is starting to get old, I have been working on this for over a week 
now.

CODE:

    <html><head><title>Login</title>

    </head>
    <body>
    <?php
        
        $conn = "user=auth password=redhat
        dbname=auth host=localhost port=5432";
        
        $dbconn = pg_connect($conn);
        echo "Connected Successfully";
        
        
    ?>
    </body>
    </html>

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? in 
/var/www/html/thomas/cis166ae/database/secretdb.php on line 11
Connected Successfully


Thomas



Thomas Bonham wrote:
> I add the hostname and port, then I configure postgresql.conf and enable 
> the port 5432 line in the config file.
> 
> So this is the new code.
> 
> 
>    <html><head><title>Login</title>
> 
>    </head>
>    <body>
>    <?php
>     
>     $conn = pg_connect("
>     user=auth dbname=auth password=redhat host=thomas.example.com
>     port=5432" ) or die ("Could not connect") ;
>     echo "Connected Successfully";
>     pg_close($conn);
>     
>    ?>
>    </body>
>    </html>
> 
> With the new error.
> 
> Warning: pg_connect(): Unable to connect to PostgreSQL server: could not 
> connect to server: Connection refused Is the server running on host 
> "thomas.example.com" and accepting TCP/IP connections on port 5432? in 
> /var/www/html/thomas/cis166ae/database/secretdb.php on line 10
> Could not connect
> 
> Thomas
> 
> 
> 
> Robbert van Andel wrote:
> 
>> You might need to include the hostname and port.
>>
>> -----Original Message-----
>> From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, 
>> June 26, 2005 6:48 PM
>> To: php-db@lists.php.net
>> Subject: Re: [PHP-DB] Re: PostgreSQL error with PHP
>>
>> Thanks for the help.
>> The code now looks like this.
>> CODE:
>>
>>     <html><head><title>Login</title>
>>
>>     </head>
>>     <body>
>>     <?php
>>     
>>     $conn = pg_connect("user=auth dbname=auth password=redhat")
>>     or die ("Could not connect") ;
>>     echo "Connectd Successfully";
>>     pg_close($conn);
>>     
>>     ?>
>>     </body>
>>     </html>
>>
>> And now the error I get is the following.
>>
>>
>> Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: 
>> IDENT authentication failed for user "auth" in 
>> /var/www/html/thomas/cis166ae/database/secretdb.php on line 8
>> Could not connect
>>
>>
>> Thomas
>>
>> Robbert van Andel wrote:
>>
>>> The error is in your function pg_connect
>>> pg_connect("name=auth user=auth");
>>>
>>> I'm not a PostgreSQL user but your connection string should be enclosed
>>
>>
>> into
>>
>>> by quotes.  Documentation can be found at
>>> http://us3.php.net/manual/en/function.pg-connect.php
>>>
>>> Hope this helps,
>>> Robbert
>>>
>>> -----Original Message-----
>>> From: Thomas Bonham [mailto:[EMAIL PROTECTED] Sent: Sunday, 
>>> June 26, 2005 5:43 PM
>>> To: php-db@lists.php.net
>>> Subject: [PHP-DB] Re: PostgreSQL error with PHP
>>>
>>> I modafide the code some more and now with the following code I get 
>>> this error.
>>> CODE:
>>>  <html><head><title>Login</title>
>>>
>>>    </head>
>>>    <body>
>>>    <?php
>>>       
>>>     pg_connect(name="auth"); (user="auth");
>>>    ?>
>>>    </body>
>>>    </html>
>>>
>>>
>>> Parse error: parse error, unexpected '=' in 
>>> /var/www/html/thomas/cis166ae/database/secretdb.php on line 8
>>>
>>> Thanks
>>>
>>> Thomas Bonham wrote:
>>>
>>>
>>>> Hello All,
>>>> I'm trying to get php to connect to my PostgreSQL database.
>>>> The code that I'm using is below.
>>>>
>>>>
>>>>  <html><head><title>Login</title>
>>>>
>>>>  </head>
>>>>  <body>
>>>>  <?php
>>>>      $conn = "dbname=auth user=auth";
>>>>   $db = pg_connect ( $conn );
>>>>  ?>
>>>>  </body>
>>>>  </html>
>>>>
>>>> Warning: pg_connect(): Unable to connect to PostgreSQL server: 
>>>> FATAL: IDENT authentication failed for user "auth" in 
>>>> /var/www/html/thomas/cis166ae/database/secretdb.php on line 8
>>>>
>>>> Below is how I set up my database.
>>>>
>>>> [EMAIL PROTECTED] # Su - postgres
>>>>
>>>> -bash-3.00$ createuser -D -A -E
>>>>       auth
>>>> -bash-3.00$ createdb auth
>>>>
>>>> Thanks Helping
>>>
>>>
>>>
>>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to