Re: pg_connect: Call to undefined function pg_connect()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2023-12-05 at 16:41 -0500, John wrote:
> On Tue, 2023-12-05 at 16:14 -0500, Aziz Saleh wrote:
> > Check the php.ini and see that it has the extension set/uncommented (php_pgsql.dll). If that
> > doesn't solve it try installing the php8.0-pgsql package.
> > 
> > On Tue, Dec 5, 2023 at 4:08 PM John <john.iliffe@xxxxxxxxx> wrote:
> > > I have moved a number of php scripts from PHP 7.2.9 to PHP 8.0.27 and I am encountering the
> > > following error:
> > > [05-Dec-2023 15:34:41 America/Toronto] PHP Fatal error:  Uncaught Error: Call to undefined
> > > function
> > > pg_connect() in /usr/httpd/xxx0002.php:211
> > > 
> > > line 211, which worked as expected up until now is:
> > >   $db_handle = pg_connect('dbname=xxxx user=xxxx password=xxxx');
> > > and the online docs show this as still acceptable but deprecated.  I noticed that the result
> > > will be
> > > a "PgSql\Connection" object.
> > > 
> > > Two questions:
> > > 1. since the syntax is still valid why am I getting an undefined function error?
> > > 
> > > 2. since the result is different, am I going to encounter a lot of other problems in this
> > > conversion
> > > and where can I find a full list of these changes?
> > > 
> > > Thanks,
> > > 
> > > John
> > > ======
> Thanks; I'll read the change log file this evening.
> 
> I checked the init file and this is all that is set for pgsql (exclude comment lines)
> 
> [PostgreSQL]
>    1181 pgsql.allow_persistent = On
>    1183 ; Detect broken persistent links always with pg_pconnect().
>    1186 pgsql.auto_reset_persistent = Off
>    1190 pgsql.max_persistent = -1
>    1194 pgsql.max_links = -1
>    1199 pgsql.ignore_notice = 0
> 
> Since this is the O/S supplied version of PHP I would really prefer to make as few changes as
> possible to avoid having an unknown crash sometime when the source makes the next update!  

OK, found the problem.  The default installation from Rocky did not include the parts of PHP that
handle databases.  I found a reference on an old Stack Overflow question that suggested check
phpinfo to see if support for a specific function is included.  Did a dnf install php-pgsql which 
installed a number of functions and libpq, then restarted php and postgresql (both needed) and
everything came up properly.  Seems I also upgraded to PHP 8.0.30 as a side effect.

Thanks for the help and suggestions which got me on track to find it.

John
======




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux