tags:

views:

323

answers:

4

Hi Guys, 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.

+1  A: 

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.

cletus
A: 

You also need a line

 extension=php_pgsql.dll

in your configuration to use Postgres in PHP.

Martin v. Löwis
A: 

I have the same problem and no solution. Please help.

A: 

All the above answers not solve the problem. Please help.