At work I was recently asked to help with creating a web-based tool… which sounded all great until I found out it was a IIS/PHP5/postgresql. PHP5 – no problem, IIS … sucks, very little experience with it, postgresql – never used! Unfortunately, I found that a few things had not been set up correctly…

Firstly, when trying to connect no error was even displayed … just a blank page. My php code was fine .. I would have at least expected an error message similar to:

PHP Fatal error: Call to undefined function: pg_connect() in
C:INETPUBWWWROOTindex.php on line xx

but nothing was displayed.. so I finally concluded that the postgresql module for php5 was installed and set to load. No, it was not, so I uncommented the following in c:\php5\php.ini (replace the 5 with 4 or remove as applicable):

ext=php_pgsql.dll

For some versions of php, the following may need to be uncommented instead:

extension=php_pgsql.dll

Finally, I checked that extension_dir was set correctly in c:\php5\php.ini (e.g. to c:\php5\ext in my case) to ensure it’s loaded up by IIS (for some versions of php it may be different, e.g. c:\php5\extensions – replace the 5 with 4 or remove as appropriate) and then restarted the webserver. Woohoo, finally I was able to connect to postgresql… actually, I got an error message due to permission problems. The error message was similar to:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission
denied for relation employee in C:INETPUBWWWROOTindex.php on line xx

.. fortunately, this was easily fixed by changing the user’s access permissions to the database and then restarting postgresql.

Surely there is more fun to come when developing sites running an IIS environment…

Share and Enjoy:
  • Twitter
  • StumbleUpon
  • Facebook
  • del.icio.us
  • Mixx
  • Propeller
  • BlinkList
  • Simpy

Related posts:

  1. PHP: Check For An Empty Value In An Array
  2. Grrrr… openSUSE 10.2