Thread: Undefined function pg_connect()
Hello, all.
I had installed php + postgresql on Fedora12. When the php script call to "pg_connect()", the following message is displayed:
Fatal error: Call to undefined function pg_connect() in /var/www/html/ ..... Call Stack: 0.0325 487160 1. {main}() ....
What i can do?
Thank you, in advance.
-------------------------
Gustavo Amarilla
I had installed php + postgresql on Fedora12. When the php script call to "pg_connect()", the following message is displayed:
Fatal error: Call to undefined function pg_connect() in /var/www/html/ ..... Call Stack: 0.0325 487160 1. {main}() ....
What i can do?
Thank you, in advance.
-------------------------
Gustavo Amarilla
Gustavo Amarilla Santacruz wrote: > Hello, all. > > I had installed php + postgresql on Fedora12. When the php script call > to "pg_connect()", the following message is displayed: > > Fatal error: Call to undefined function pg_connect() in /var/www/html/ > ..... Call Stack: 0.0325 487160 1. {main}() .... > > > What i can do? You need the php-pgsql package if you installed via rpm. Once you have that installed, restart apache and see how you go. -- Postgresql & php tutorials http://www.designmagick.com/
On Wed, 2010-01-27 at 21:25 -0300, Gustavo Amarilla Santacruz wrote: > I had installed php + postgresql on Fedora12. When the php script call > to "pg_connect()", the following message is displayed: > > Fatal error: Call to undefined function pg_connect() If you are installing from RPMs, you also need to install php-pgsql package. If you are installing from sources, you will need to recompile with PostgreSQL support. -- Devrim GÜNDÜZ, RHCE Command Prompt - http://www.CommandPrompt.com devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr http://www.gunduz.org Twitter: http://twitter.com/devrimgunduz
Thank you, Chris.
I use the yum command and i got the following result:
yum install php-pgsql
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Package php-pgsql-5.3.1-1.fc12.i686 already installed and latest version
Nothing to do
What i can do?
Thank you, in advance.
---------------------------
Gustavo Amarilla
I use the yum command and i got the following result:
yum install php-pgsql
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Package php-pgsql-5.3.1-1.fc12.i686 already installed and latest version
Nothing to do
What i can do?
Thank you, in advance.
On Wed, Jan 27, 2010 at 9:36 PM, Chris <dmagick@gmail.com> wrote:
Gustavo Amarilla Santacruz wrote:You need the php-pgsql package if you installed via rpm.Hello, all.
I had installed php + postgresql on Fedora12. When the php script call to "pg_connect()", the following message is displayed:
Fatal error: Call to undefined function pg_connect() in /var/www/html/ ..... Call Stack: 0.0325 487160 1. {main}() ....
What i can do?
Once you have that installed, restart apache and see how you go.
--
Postgresql & php tutorials
http://www.designmagick.com/
---------------------------
Gustavo Amarilla
In response to Gustavo Amarilla Santacruz <gusamasan@gmail.com>: > Thank you, Chris. > > I use the yum command and i got the following result: > > yum install php-pgsql > Loaded plugins: presto, refresh-packagekit > Setting up Install Process > Package php-pgsql-5.3.1-1.fc12.i686 already installed and latest version > Nothing to do Have you restarted Apache since it was successfully installed? -- Bill Moran http://www.potentialtech.com http://people.collaborativefusion.com/~wmoran/
Thank you, Bill Moran.
My httpd is stoped, for default.
I used the command: service httpd start; then, the following message was displayed:
Starting httpd: [Thu Jan 28 20:27:39 2010] [warn] module perl_module is already loaded, skipping
[Thu Jan 28 20:27:39 2010] [warn] module php5_module is already loaded, skipping
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
But the pg_connect function is not recognized.
--
Gustavo Amarilla
¿Reciclaste papel, hoy?
My httpd is stoped, for default.
I used the command: service httpd start; then, the following message was displayed:
Starting httpd: [Thu Jan 28 20:27:39 2010] [warn] module perl_module is already loaded, skipping
[Thu Jan 28 20:27:39 2010] [warn] module php5_module is already loaded, skipping
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
But the pg_connect function is not recognized.
On Thu, Jan 28, 2010 at 10:44 AM, Bill Moran <wmoran@potentialtech.com> wrote:
In response to Gustavo Amarilla Santacruz <gusamasan@gmail.com>:Have you restarted Apache since it was successfully installed?
> Thank you, Chris.
>
> I use the yum command and i got the following result:
>
> yum install php-pgsql
> Loaded plugins: presto, refresh-packagekit
> Setting up Install Process
> Package php-pgsql-5.3.1-1.fc12.i686 already installed and latest version
> Nothing to do
--
Gustavo Amarilla
¿Reciclaste papel, hoy?
Gustavo Amarilla Santacruz wrote: > Thank you, Bill Moran. > > My httpd is stoped, for default. > > I used the command: service httpd start; then, the following message was > displayed: > > Starting httpd: [Thu Jan 28 20:27:39 2010] [warn] module perl_module is > already loaded, skipping > [Thu Jan 28 20:27:39 2010] [warn] module php5_module is already loaded, > skipping > httpd: Could not reliably determine the server's fully qualified domain > name, using localhost.localdomain for ServerName > [ OK ] > > > But the pg_connect function is not recognized. Does a phpinfo() page show it loading anything re: pgsql ? Anything in apache logs (/var/log/httpd/error.log probably) ? Could seLinux be involved somehow (I'm not really sure where to look for this, something in /var/log should have some info) ? On your phpinfo page, it should have something like this: Configuration File (php.ini) Path /etc/php.ini Scan this dir for additional .ini files /etc/php.d Check whether the rpm put a file in that extra directory, like: # cat /etc/php.d/pgsql.ini ; Enable pgsql extension module extension=pgsql.so If it didn't, try doing it manually (and restart httpd) and see if pgsql shows up in your phpinfo page now. -- Postgresql & php tutorials http://www.designmagick.com/
On Thu, Jan 28, 2010 at 8:53 PM, Chris <dmagick@gmail.com> wrote:
Gustavo Amarilla Santacruz wrote:Does a phpinfo() page show it loading anything re: pgsql ?Thank you, Bill Moran.
My httpd is stoped, for default.
I used the command: service httpd start; then, the following message was displayed:
Starting httpd: [Thu Jan 28 20:27:39 2010] [warn] module perl_module is already loaded, skipping
[Thu Jan 28 20:27:39 2010] [warn] module php5_module is already loaded, skipping
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
But the pg_connect function is not recognized.
Anything in apache logs (/var/log/httpd/error.log probably) ?
Could seLinux be involved somehow (I'm not really sure where to look for this, something in /var/log should have some info) ?
On your phpinfo page, it should have something like this:
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
Check whether the rpm put a file in that extra directory, like:
# cat /etc/php.d/pgsql.ini
; Enable pgsql extension module
extension=pgsql.so
If it didn't, try doing it manually (and restart httpd) and see if pgsql shows up in your phpinfo page now.
Thank you, Chris
1) Does a phpinfo() page show it loading anything re: pgsql ?
No, no matter info on pgsql.
2) Anything in apache logs (/var/log/httpd/error.log probably) ?
Yes, i found this:
.
.
.
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/curl.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/fileinfo.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/fileinfo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/json.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/ldap.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/mysql.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
.
.
.
3) On your phpinfo page, it should have something like this:
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
Yes, the phpinfo page has this information.
4) Check whether the rpm put a file in that extra directory, like:
# cat /etc/php.d/pgsql.ini
; Enable pgsql extension module
extension=pgsql.so
Yes, the rpm put that file in /etc/php.d
----------------------------
Gustavo Amarilla
On Fri, Jan 29, 2010 at 10:07 PM, Gustavo Amarilla Santacruz <gusamasan@gmail.com> wrote:
Thank you, ChrisOn Thu, Jan 28, 2010 at 8:53 PM, Chris <dmagick@gmail.com> wrote:Gustavo Amarilla Santacruz wrote:Does a phpinfo() page show it loading anything re: pgsql ?Thank you, Bill Moran.
My httpd is stoped, for default.
I used the command: service httpd start; then, the following message was displayed:
Starting httpd: [Thu Jan 28 20:27:39 2010] [warn] module perl_module is already loaded, skipping
[Thu Jan 28 20:27:39 2010] [warn] module php5_module is already loaded, skipping
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
But the pg_connect function is not recognized.
Anything in apache logs (/var/log/httpd/error.log probably) ?
Could seLinux be involved somehow (I'm not really sure where to look for this, something in /var/log should have some info) ?
On your phpinfo page, it should have something like this:
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
Check whether the rpm put a file in that extra directory, like:
# cat /etc/php.d/pgsql.ini
; Enable pgsql extension module
extension=pgsql.so
If it didn't, try doing it manually (and restart httpd) and see if pgsql shows up in your phpinfo page now.
1) Does a phpinfo() page show it loading anything re: pgsql ?
No, no matter info on pgsql.
2) Anything in apache logs (/var/log/httpd/error.log probably) ?
Yes, i found this:
.
.
.
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/curl.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/fileinfo.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/fileinfo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/json.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/ldap.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/mysql.so' - ./;/usr/lib/php/modules/;/usr/lib/pgsql/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
.
.
.
3) On your phpinfo page, it should have something like this:
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
Yes, the phpinfo page has this information.
4) Check whether the rpm put a file in that extra directory, like:
# cat /etc/php.d/pgsql.ini
; Enable pgsql extension module
extension=pgsql.so
Yes, the rpm put that file in /etc/php.d
----------------------------
Gustavo Amarilla
I commented the php.ini line in the extension_dir parameter:
Before:
.
.
.
; Directory in which the loadable extensions (modules) reside.
; http://www.php.net/manual/en/ini.core.php#ini.extension-dir
; extension_dir = "./"
extension_dir = "./;/usr/lib/php/modules/;/usr/lib/pgsql/"
.
.
.
After:
.
.
.
; Directory in which the loadable extensions (modules) reside.
; http://www.php.net/manual/en/ini.core.php#ini.extension-dir
; extension_dir = "./"
;extension_dir = "./;/usr/lib/php/modules/;/usr/lib/pgsql/"
.
.
.
Then, a new message was displayed:
"Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "localhost" and accepting TCP/IP connections on port 5432? could not connect to server: Permission denied Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?"
The pg_hba.conf file containt:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 ident
What i can do?
Thank you, in advance.
--------------------------
Gustavo Amarilla
On 30/01/2010 12:33, Gustavo Amarilla Santacruz wrote: > "Warning: pg_connect(): Unable to connect to PostgreSQL server: could > not connect to server: Permission denied Is the server running on host > "localhost" and accepting TCP/IP connections on port 5432? could not > connect to server: Permission denied Is the server running on host > "localhost" and accepting TCP/IP connections on port 5432?" > > > > > The pg_hba.conf file containt: > Sounds like you're getting somewhere - the PG extension is being found now. The error above is nothing to do with pg_hba.conf; if the connection was being denied because of a rule there, the error would say so explicitly. Rather, it's a network problem of some kind. Is the server actually running? Is there a firewall preventing access? Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
> ; Directory in which the loadable extensions (modules) reside. > ; http://www.php.net/manual/en/ini.core.php#ini.extension-dir > ; extension_dir = "./" > ;extension_dir = "./;/usr/lib/php/modules/;/usr/lib/pgsql/" These should be colon separated, not semicolon - notice it's trying to load both paths included: PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/curl.so' Change it to extension_dir = "./:/usr/lib/php/modules/:/usr/lib/pgsql/" > Then, a new message was displayed: > > "Warning: pg_connect(): Unable to connect to PostgreSQL server: could > not connect to server: Permission denied Is the server running on host > "localhost" and accepting TCP/IP connections on port 5432? could not > connect to server: Permission denied Is the server running on host > "localhost" and accepting TCP/IP connections on port 5432?" "Permission denied" sounds like either file permissions or seLinux is stopping the connection. If you have seLinux enabled, try disabling it (don't know how to do that, sorry) - at least that will tell you if that's the problem. For file permissions, check your apache user can read where-ever the postgres socket file is put (normally /tmp/.s.PGSQL.5432 on centos/rhel). -- Postgresql & php tutorials http://www.designmagick.com/
Thank you, all.
I had access to the SELinux->Boolean; next, i check the option:
"Allow HTTPD scripts and modules to connect to databases over the network".
Then, a new message was displayed:
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident authentication failed for user "gestock" .......
I can login with gestock data (user/password) through the postgresql psql tool. But from apache i can not.
Note: the php.ini file was not modified.
--
Gustavo Amarilla
I had access to the SELinux->Boolean; next, i check the option:
"Allow HTTPD scripts and modules to connect to databases over the network".
Then, a new message was displayed:
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident authentication failed for user "gestock" .......
I can login with gestock data (user/password) through the postgresql psql tool. But from apache i can not.
Note: the php.ini file was not modified.
On Sun, Jan 31, 2010 at 7:21 PM, Chris <dmagick@gmail.com> wrote:
These should be colon separated, not semicolon - notice it's trying to load both paths included:; Directory in which the loadable extensions (modules) reside.
; http://www.php.net/manual/en/ini.core.php#ini.extension-dir
; extension_dir = "./"
;extension_dir = "./;/usr/lib/php/modules/;/usr/lib/pgsql/"Change it to
PHP Warning: PHP Startup: Unable to load dynamic library './;/usr/lib/php/modules/;/usr/lib/pgsql/curl.so'"Permission denied" sounds like either file permissions or seLinux is stopping the connection.
extension_dir = "./:/usr/lib/php/modules/:/usr/lib/pgsql/"Then, a new message was displayed:
"Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "localhost" and accepting TCP/IP connections on port 5432? could not connect to server: Permission denied Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?"
If you have seLinux enabled, try disabling it (don't know how to do that, sorry) - at least that will tell you if that's the problem.
For file permissions, check your apache user can read where-ever the postgres socket file is put (normally /tmp/.s.PGSQL.5432 on centos/rhel).
--
Gustavo Amarilla
Gustavo Amarilla Santacruz wrote: > Thank you, all. > > I had access to the SELinux->Boolean; next, i check the option: > > "Allow HTTPD scripts and modules to connect to databases over the > network". > > > Then, a new message was displayed: > > Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: > Ident authentication failed for user "gestock" ....... > > > I can login with gestock data (user/password) through the postgresql > psql tool. But from apache i can not. It's not using the password, it's just checking the username to see if you're logged in as 'gestock' (but 'apache' is not 'gestock', hence the error). What does your postgresql pg_hba.conf file look like? -- Postgresql & php tutorials http://www.designmagick.com/
Thank you, Chris.
The pg_hba.conf contained:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 ident
Before, i modified to:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 trust
Then i can login me. But, how i Know that apache is using IPV6 connections?
--
Gustavo Amarilla
¿Reciclaste papel, hoy?
The pg_hba.conf contained:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 ident
Before, i modified to:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 trust
Then i can login me. But, how i Know that apache is using IPV6 connections?
On Mon, Feb 1, 2010 at 9:13 PM, Chris <dmagick@gmail.com> wrote:
Gustavo Amarilla Santacruz wrote:It's not using the password, it's just checking the username to see if you're logged in as 'gestock' (but 'apache' is not 'gestock', hence the error).Thank you, all.
I had access to the SELinux->Boolean; next, i check the option:
"Allow HTTPD scripts and modules to connect to databases over the network".
Then, a new message was displayed:
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident authentication failed for user "gestock" .......
I can login with gestock data (user/password) through the postgresql psql tool. But from apache i can not.
What does your postgresql pg_hba.conf file look like?
--
Gustavo Amarilla
¿Reciclaste papel, hoy?
I am sorry. Please, ommit the previous post.
The correct post is the following:
Thank you, Chris.
The pg_hba.conf file contained this:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 ident
After, i modified it to:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 trust
Then i can login me from php scripts. But, how i Know that apache is using IPV6 connections?
--
Gustavo Amarilla
¿Reciclaste papel, hoy?
The correct post is the following:
Thank you, Chris.
The pg_hba.conf file contained this:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 ident
After, i modified it to:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 trust
Then i can login me from php scripts. But, how i Know that apache is using IPV6 connections?
On Mon, Feb 1, 2010 at 9:51 PM, Gustavo Amarilla Santacruz <gusamasan@gmail.com> wrote:
Thank you, Chris.
The pg_hba.conf contained:Before, i modified to:
# 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 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 identhost all all ::1/128 trust
# 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 255.255.255.0 trust
# IPv6 local connections:
Then i can login me. But, how i Know that apache is using IPV6 connections?On Mon, Feb 1, 2010 at 9:13 PM, Chris <dmagick@gmail.com> wrote:Gustavo Amarilla Santacruz wrote:It's not using the password, it's just checking the username to see if you're logged in as 'gestock' (but 'apache' is not 'gestock', hence the error).Thank you, all.
I had access to the SELinux->Boolean; next, i check the option:
"Allow HTTPD scripts and modules to connect to databases over the network".
Then, a new message was displayed:
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident authentication failed for user "gestock" .......
I can login with gestock data (user/password) through the postgresql psql tool. But from apache i can not.
What does your postgresql pg_hba.conf file look like?--
Gustavo Amarilla
¿Reciclaste papel, hoy?
--
Gustavo Amarilla
¿Reciclaste papel, hoy?