Thread: PostgreSQL + PHP can't connect

PostgreSQL + PHP can't connect

From
Jordi Scharp
Date:
Hello there all,

I have a huuuuuuuuuuuuge problem!

I have a PosgreSQL database running called testjordi (Jordi's my name ;)) and I'm connecting it to port 113 (I really don't know which port to use but all other give an instant error msg and 113 doesn't so I think that's the right one). 
Second of all I've made a php file with the following contents

<HTML>
<HEAD>
<TITLE>pg_exec</TITLE>
</HEAD>
<BODY>
<?
        $connection = pg_connect("localhost",
                "113", "testjordi");

        pg_close($connection);
?>
</BODY>
</HTML>

just to test whether it can connect or not..
when I load it it keeps loading for a helluvalong time.. about maybe 4 mins... and then replies:
-=-
Warning: Unable to connect to PostgresSQL server: pqReadData() -- backend closed the channel unexpectedly. This probably means the backend terminated abnormally before or while processing the request. in /usr/local/apache/htdocs/pg_exec.php3 on line 8

Warning: 0 is not a PostgresSQL link index in /usr/local/apache/htdocs/pg_exec.php3 on line 10

-=-

The Line 10 error is ofcourse caused cuz it can't connect in line 8..
does anyone know what the problem is? 


php_info() replies with

PostgreSQL
Allow persistent links: Yes
Persistent links: 0/Unlimited
Total links: 0/Unlimited
Compilation definitions: PGSQL_INCLUDE=
PGSQL_LFLAGS=
PGSQL_LIBS=
 
-=-

does anyone has a clue.. if so PLEASE I'M BEGGING reply.. it's very important...

Thanks very much,
-Jordi

Re: PostgreSQL + PHP can't connect

From
Patrick Welche
Date:
On Sun, Sep 10, 2000 at 09:03:50PM +0200, Jordi Scharp wrote:
> Hello there all,
>
> I have a huuuuuuuuuuuuge problem!
>
> I have a PosgreSQL database running called testjordi (Jordi's my name
> ;)) and I'm connecting it to port 113 (I really don't know which port to
> use but all other give an instant error msg and 113 doesn't so I think
> that's the right one).

How about 5432 ? (recollect 113 has something to do with auth/ident)
Did you start postmaster with -i ? Can you connect directly with psql?
What does pg_hba.conf look like? Did you grant your database rights to
read your table?

All questions... no answers...

Cheers,

Patrick

Re: PostgreSQL + PHP can't connect

From
"Mike Sears"
Date:
You might want to check to see if php was corectly compiled to use php
 
also your pg_connect() does not seem right.
You aren't giving a username to access the database testjordi. As well if you compiled Postgres, and didn't specify your port in the ./config then you don't need to specify the port # in your pg_connect()
Try this out and see if this works for ya.
 
 
$db = pg_connect( "host=localhost user=postgres dbname=testjordi" );
 
Mike Sears
Web Developer
www.vianet.ca
----- Original Message -----
Sent: Sunday, September 10, 2000 12:03 PM
Subject: [GENERAL] PostgreSQL + PHP can't connect

Hello there all,

I have a huuuuuuuuuuuuge problem!

I have a PosgreSQL database running called testjordi (Jordi's my name ;)) and I'm connecting it to port 113 (I really don't know which port to use but all other give an instant error msg and 113 doesn't so I think that's the right one). 
Second of all I've made a php file with the following contents

<HTML>
<HEAD>
<TITLE>pg_exec</TITLE>
</HEAD>
<BODY>
<?
        $connection = pg_connect("localhost",
                "113", "testjordi");

        pg_close($connection);
?>
</BODY>
</HTML>

just to test whether it can connect or not..
when I load it it keeps loading for a helluvalong time.. about maybe 4 mins... and then replies:
-=-
Warning: Unable to connect to PostgresSQL server: pqReadData() -- backend closed the channel unexpectedly. This probably means the backend terminated abnormally before or while processing the request. in /usr/local/apache/htdocs/pg_exec.php3 on line 8

Warning: 0 is not a PostgresSQL link index in /usr/local/apache/htdocs/pg_exec.php3 on line 10

-=-

The Line 10 error is ofcourse caused cuz it can't connect in line 8..
does anyone know what the problem is? 


php_info() replies with

PostgreSQL
Allow persistent links: Yes
Persistent links: 0/Unlimited
Total links: 0/Unlimited
Compilation definitions: PGSQL_INCLUDE=
PGSQL_LFLAGS=
PGSQL_LIBS=
 
-=-

does anyone has a clue.. if so PLEASE I'M BEGGING reply.. it's very important...

Thanks very much,
-Jordi

Re: PostgreSQL + PHP can't connect

From
"Adam Lang"
Date:
Is postgres running on the same server as PHP?  If not, Mike Sears solution
of localhost won't work.

He is correct about not needing to specify the port number if you left it as
default.

My connection string looks like this:

$dbconnection = pg_Connect("host=".$host." user=".$user."
password=".$password." dbname=".$dbna
me);

Where the variables are assigned values beforehand.

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "Jordi Scharp" <spaceface@cable.a2000.nl>
To: <pgsql-general@postgresql.org>
Sent: Sunday, September 10, 2000 3:03 PM
Subject: [GENERAL] PostgreSQL + PHP can't connect


> Hello there all,
>
> I have a huuuuuuuuuuuuge problem!
>
> I have a PosgreSQL database running called testjordi (Jordi's my name
> ;)) and I'm connecting it to port 113 (I really don't know which port to
> use but all other give an instant error msg and 113 doesn't so I think
> that's the right one).
> Second of all I've made a php file with the following contents
>
> <HTML>
> <HEAD>
> <TITLE>pg_exec</TITLE>
> </HEAD>
> <BODY>
> <?
>         $connection = pg_connect("localhost",
>                 "113", "testjordi");
>
>         pg_close($connection);
> ?>
> </BODY>
> </HTML>
>
> just to test whether it can connect or not..
> when I load it it keeps loading for a helluvalong time.. about maybe 4
> mins... and then replies:
> -=-
> Warning: Unable to connect to PostgresSQL server: pqReadData() --
> backend closed the channel unexpectedly. This probably means the backend
> terminated abnormally before or while processing the request. in
> /usr/local/apache/htdocs/pg_exec.php3 on line 8
>
> Warning: 0 is not a PostgresSQL link index in
> /usr/local/apache/htdocs/pg_exec.php3 on line 10
>
> -=-
>
> The Line 10 error is ofcourse caused cuz it can't connect in line 8..
> does anyone know what the problem is?
>
> php_info() replies with
>
> PostgreSQL
> Allow persistent links: Yes
> Persistent links: 0/Unlimited
> Total links: 0/Unlimited
> Compilation definitions: PGSQL_INCLUDE=
> PGSQL_LFLAGS=
> PGSQL_LIBS=
>
> -=-
>
> does anyone has a clue.. if so PLEASE I'M BEGGING reply.. it's very
> important...
>
> Thanks very much,
> -Jordi
>


Re: PostgreSQL + PHP can't connect

From
"Rommel B. Abaya"
Date:
i think you should use port 5432. this is the default port of PostgreSQL  unless of course your SysAdmin changed it to something else.
 

Jordi Scharp wrote:

Hello there all,

I have a huuuuuuuuuuuuge problem!

I have a PosgreSQL database running called testjordi (Jordi's my name ;)) and I'm connecting it to port 113 (I really don't know which port to use but all other give an instant error msg and 113 doesn't so I think that's the right one).
Second of all I've made a php file with the following contents

<HTML>
<HEAD>
<TITLE>pg_exec</TITLE>
</HEAD>
<BODY>
<?
        $connection = pg_connect("localhost",
                "113", "testjordi");

        pg_close($connection);
?>
</BODY>
</HTML>

just to test whether it can connect or not..
when I load it it keeps loading for a helluvalong time.. about maybe 4 mins... and then replies:
-=-
Warning: Unable to connect to PostgresSQL server: pqReadData() -- backend closed the channel unexpectedly. This probably means the backend terminated abnormally before or while processing the request. in /usr/local/apache/htdocs/pg_exec.php3 on line 8

Warning: 0 is not a PostgresSQL link index in /usr/local/apache/htdocs/pg_exec.php3 on line 10

-=-

The Line 10 error is ofcourse caused cuz it can't connect in line 8..
does anyone know what the problem is?
 

php_info() replies with

PostgreSQL
Allow persistent links: Yes
Persistent links: 0/Unlimited
Total links: 0/Unlimited
Compilation definitions: PGSQL_INCLUDE=
PGSQL_LFLAGS=
PGSQL_LIBS=

-=-

does anyone has a clue.. if so PLEASE I'M BEGGING reply.. it's very important...

Thanks very much,
-Jordi

test

From
"Kane Tao"
Date:
Hmm is the list down or is everyone without questions?