Обсуждение: Accessing PostgreSQL through Apache and PHP4 on Linux
I am running PostgreSQL 7.1.3, RedHat 7.1 (kernel 2.4.2-2), and PHP/4.0.4pl1. When I try to run a PHP page found below I get an error that says:
Fatal error: Call to undefined function: pg_connect() in /var/www/html/psolver.php on line 10
Additionally, even though pgsql.so IS in /usr/lib/php4 (and php.ini tells PHP to look there for extensions), I get the following error on the call to dl().
Warning: Unable to load dynamic library '/usr/lib/php4/pgsql.so' - libpq.so: cannot load shared object file: No such file or directory in /var/www/html/psolver.php on line 7
Code snippet:
-----------------------------------------------------------------------------------------------
<?
dl("pgsql.so");
//connect to database
$conn = pg_connect("","","","psolver");
if(!$conn) {
print("Couldn't connect to psolver");
exit;
}
?>
Chances are, ld can't find libpq.so. Try adding the location of libpq.so
(usually /usr/lib/pgsql or /usr/local/lib/pgsql, but you can use whereis to
find out exactly where) to /etc/ld.so.conf, then run ldconfig. If it is an
ld problem, that should fix it.
Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"
From: "Holt, Jack C." <JACK.C.HOLT@saic.com>
Date: Thu, 18 Oct 2001 07:55:42 -0700
To: pgsql-general@postgresql.org
Subject: [GENERAL] Accessing PostgreSQL through Apache and PHP4 on Linux
I am running PostgreSQL 7.1.3, RedHat 7.1 (kernel 2.4.2-2), and
PHP/4.0.4pl1. When I try to run a PHP page found below I get an error that
says:
Fatal error: Call to undefined function: pg_connect() in
/var/www/html/psolver.php on line 10
Additionally, even though pgsql.so IS in /usr/lib/php4 (and php.ini tells
PHP to look there for extensions), I get the following error on the call to
dl().
Warning: Unable to load dynamic library '/usr/lib/php4/pgsql.so' - libpq.so:
cannot load shared object file: No such file or directory in
/var/www/html/psolver.php on line 7
Code snippet:
----------------------------------------------------------------------------
-------------------
<?
dl("pgsql.so");
//connect to database
$conn = pg_connect("","","","psolver");
if(!$conn) {
print("Couldn't connect to psolver");
exit;
}
?>
It looks like PHP was compiled without the PostgreSQL
option. I know that Caldera's and Slackware's PHP
packages do not support PostgreSQL by default.
SuSE's does; but I'm not sure about RedHat's.
Best of luck,
Andrew
--- "Holt, Jack C." <JACK.C.HOLT@saic.com> wrote:
> I am running PostgreSQL 7.1.3, RedHat 7.1 (kernel
> 2.4.2-2), and
> PHP/4.0.4pl1. When I try to run a PHP page found
> below I get an error that
> says:
>
> Fatal error: Call to undefined function:
> pg_connect() in
> /var/www/html/psolver.php on line 10
>
> Additionally, even though pgsql.so IS in
> /usr/lib/php4 (and php.ini tells
> PHP to look there for extensions), I get the
> following error on the call to
> dl().
>
> Warning: Unable to load dynamic library
> '/usr/lib/php4/pgsql.so' - libpq.so:
> cannot load shared object file: No such file or
> directory in
> /var/www/html/psolver.php on line 7
>
> Code snippet:
>
----------------------------------------------------------------------------
> -------------------
> <?
> dl("pgsql.so");
>
> //connect to database
> $conn = pg_connect("","","","psolver");
> if(!$conn) {
> print("Couldn't connect to psolver");
> exit;
> }
> ?>
>
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
Thanx. I'll do that.
-----Original Message-----
From: Mitch Vincent [mailto:mvincent@cablespeed.com]
Sent: Thursday, October 18, 2001 10:32 AM
To: Holt, Jack C.
Subject: Re: [GENERAL] Accessing PostgreSQL through Apache and PHP4
on Linux
You didn't compile PHP with PostgreSQL support.
Recompile and add --with-pgsql to the configure line.
----- Original Message -----
From: "Holt, Jack C." <JACK.C.HOLT@saic.com>
To: <pgsql-general@postgresql.org>
Sent: Thursday, October 18, 2001 10:55 AM
Subject: [GENERAL] Accessing PostgreSQL through Apache and PHP4 on Linux
> I am running PostgreSQL 7.1.3, RedHat 7.1 (kernel 2.4.2-2), and
> PHP/4.0.4pl1. When I try to run a PHP page found below I get an error
that
> says:
>
> Fatal error: Call to undefined function: pg_connect() in
> /var/www/html/psolver.php on line 10
>
> Additionally, even though pgsql.so IS in /usr/lib/php4 (and php.ini tells
> PHP to look there for extensions), I get the following error on the call
to
> dl().
>
> Warning: Unable to load dynamic library '/usr/lib/php4/pgsql.so' -
libpq.so:
> cannot load shared object file: No such file or directory in
> /var/www/html/psolver.php on line 7
>
> Code snippet:
> --------------------------------------------------------------------------
--
> -------------------
> <?
> dl("pgsql.so");
>
> //connect to database
> $conn = pg_connect("","","","psolver");
> if(!$conn) {
> print("Couldn't connect to psolver");
> exit;
> }
> ?>
>
Re: Accessing PostgreSQL through Apache and PHP4 on Linux
"Holt, Jack C." <JACK.C.HOLT@saic.com> writes: > I am running PostgreSQL 7.1.3, RedHat 7.1 (kernel 2.4.2-2) Psst... you should apply available updates. > Fatal error: Call to undefined function: pg_connect() in > /var/www/html/psolver.php on line 10 You need install the php-pgsql rpm. -- Trond Eivind Glomsrød Red Hat, Inc.
On Thu, 18 Oct 2001 11:34:21 -0700 (PDT) Andrew Gould <andrewgould@yahoo.com> wrote:
> It looks like PHP was compiled without the PostgreSQL
> option. I know that Caldera's and Slackware's PHP
> packages do not support PostgreSQL by default.
> SuSE's does; but I'm not sure about RedHat's.
on RedHat 7.1, you need to install the following RPM to get pgsql support
for php:
php-pgsql-4.0.4pl1-9
it's on one of the CDs in all the distributions (i forget which CD), or
available from the RedHat ftp download site.
richard