[MS4W-Users] Fatal error: Call to undefined function pg_connect()

Jeff McKenna jmckenna at gatewaygeomatics.com
Wed May 26 16:10:52 EST 2010

Hello Steve,

You can test what PHP extensions are loaded at the commandline by: 1) 
executing 'setenv.bat' at the command prompt, then 2) executing 'php -i' 
and possibly output that to a file with 'php -i > phpinfo.txt' and 
search for 'pgsql'.

If you are using MS4W version 3.0 you don't need to load the dll in your 
php.ini, as it is already loaded dynamically (indeed if you are hitting 
a hard wall with an old MS4W version here is the reason you need to 

I have successfully tested just now with MS4W 3.0 beta11 and an old MS4W 
2.3.1 with a php file that only contains '<?php pg_connect(); ?>' (I get 
a 'wrong parameter' warning as expected).

Thank you for using the MS4W product, I hope it helps you share your 
spatial information.


Jeff McKenna
MapServer Consulting and Training Services

Steve.Toutant at inspq.qc.ca wrote:
> Hi,
> I created a php that works well when launched from a browser.
> But it doesn't from a command line
> PHP myFile.php
> I get this error
> Fatal error: Call to undefined function pg_connect()
> It seems that php.exe does not recognize postgres functions.
> In \ms4w\Apache\cgi-bin\php.ini I have this:
> extension=php_pgsql.dll and this dll is in \ms4w\Apache\php\ext
> PATH variable contains this
> C:\Program Files\PostgreSQL\8.3\bin;
> phpinfo() give me this
> What should I do to be able to call the postgres functions when using 
> php.exe from a command line?

More information about the MS4W-Users mailing list