Reputation:
I can't fix this problem. I have installed "php-5.2.10-win32-installer.msi" and "apache_2.2.11-win32-x86-no_ssl.msi", and "mysql-4.1.22-win32" on my XP. When I try to use phpinfo print out database support, I can see mysql is there, but not pgsql. I checked my php.ini, there are entries like these:
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_PGSQL]
extension=php_pgsql.dll
I was wondering why MySQL is ok, but why not postgreSQL?
Following are my php script.
error_reporting(E_ALL | E_STRICT);
echo "connecting...<br>";
echo 'php.ini: ', get_cfg_var('cfg_file_path')," <br/> ";
echo extension_loaded('pgsql') ? 'yes':'no'," <br/> ";
$pg = pg_connect("host=localhost user=postgres
password=xx dbname=xx")
or die("Can't connect to database.");
echo "connected<br>";
?>
result is:
connecting... php.ini: C:\Program Files\PHP\php.ini no
Fatal error: Call to undefined function pg_connect() in E:\WebSite\index.php on line 19
I checked my php.ini, it has above "dll" entries I mentioned, please help.
Upvotes: 1
Views: 6910
Reputation: 127477
You also need a line
extension=php_pgsql.dll
in your configuration to use Postgres in PHP.
Upvotes: 0
Reputation: 625167
In your php.ini file change:
;extension=php_pdo_pgsql.dll
to
extension=php_pdo_pgsql.dll
and restart Apache. This adds the Postgres extension (it's commented out by default).
Also make sure you're editing the right php.ini file. I'm not familiar with the distribution you're using but I've seen some that have 2 or even 3 php.ini files floating around (eg one for Apache, one for CLI and one for I don't know what).
In XAMPP 1.7.2 this is in \xampp\php\php.ini
.
Upvotes: 2