PHP not loading php_pgsql.dll on Windows
Check out the info on the PHP PostgreSQL installation page: http://us.php.net/manual/en/pgsql.installation.php
On a Windows server, configured with Apache, adding the following line to httpd.conf to load libpq.dll can save you a lot of time :
LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"
Note that you will have to change your folder accordingly to the installation path and version of PostgreSQL you have installed. Also note that having Apache and PostgreSQL on the same server for production environments is not recommended.
This fixed my setup instantly.
PHP extension is not recognised on Windows (using PHP 7.4)
The same error is displayed if the extension DLL was compiled for a different version of PHP.
Using Windows Explorer, right-click on the DLL and select properties, then Details. Check the Product version value.
The actual issue is that PHP extensions have an API version such as 20200930. The API version must match PHP and the extension. The CLI command php -i | grep API will display this information.
PGSQL not loaded in PHP 5.3 Windows under IIS
Tried phpinfo()
again, and it reports
Loaded Configuration File = C:\Program Files (x86)\PHP\v5.3\php.ini
which is correct and contains extension=php_pdo_pgsql.dll
and extension=php_pgsql.dll
. As for "the dll's are in the right place" (@Richard), I have problems making sure exactly what dll:s are needed and where they should be located, but I have in C:\Program Files (x86)\PHP\v5.3\ext\
both php_pdo_pgsql.dll
(version 5.3.12.0) and php_pgsql.dll
(version 5.3.12.0).
I read about a dependency on libpq.dll
and this is present in C:\Program Files (x86)\PHP\v5.3\
. Early in my "debugging" I copied the new libpq.dll
(version 8.4.4.10133) from PostgreSQL to that folder, having read somewhere that it might solve the problem. I now tried reverting to the old version (8.3.6.9034) that shipped with PHP, and VOILA!!!! Suddenly phpinfo()
says it has loaded both pdo and non-pdo pgsql modules.
MantisBT now loads the login screen at least. Whew!
PostgreSQL trouble on windows PHP
xampp doesn't "tell" apache/php which php.ini to use. Therefore php uses its default lookup strategy to find the .ini file. If you haven't changed anything this will be the one in the directory where the apache binary is located, xampp/apache/bin/php.ini. Did you edit this file and removed the semicolon before extension=php_pgsql.dll ?
When in doubt ask
echo 'php.ini: ', get_cfg_var('cfg_file_path');
which file you have to edit.xampp installs php as a module by default and you have to restart the apache in order to get php to read the php.ini again.
After that
echo extension_loaded('pgsql') ? 'yes':'no';
should print yes. If it doesn't stop the apache service, open a command shell, go to your xampp directory and enterapache_start.batThis will start the apache as a console application and you can see startup errors in this console (instead of windows' event manager). If a dll is missing you will get a message box.
How do I enable php to work with postgresql?
Try this:
Uncomment the following in php.ini by removing the ";"
;extension=php_pgsql.dll
Use the following code to connect to a postgresql database server:
pg_connect("host=localhost dbname=dbname user=username password=password")
or die("Can't connect to database".pg_last_error());
PHP Startup : Unable to load dynamic library PGSQL
You must properly install the PostgreSQL module and enable it. http://php.net/manual/en/pgsql.installation.php
P.S. do not use '.dll' files on the servers with UNIX based OS, because these extensions are compiled for the Windows operating system (for UNIX based OS you must use '.so' files).
Related Topics
How to See the Extensions Loaded by PHP
What's the Best Way to Create a Single-File Upload Form Using PHP
Getting Order Data After Successful Checkout Hook
Run PHPunit Tests in Certain Order
Magento - Passing Data Between a Controller and a Block
Laravel 5:Class 'Input' Not Found
What Does Header('P3P: Cp="Cao Psa Our"'); Do
How to Document Magic (_Call and _Callstatic) Methods for Ides
Browscap Ini Directive Not Set
Process Very Big CSV File Without Timeout and Memory Error
Setting Up Domainkeys/Dkim in a PHP-Based Smtp Client
What Is Sapi and When Would You Use It