There is a minor bug in the php source code that causes compilation to fail against postgresql 7.1.
The fix is easy, and is referenced here:
http://www.php.net/bugs.php?id=10406
Basically, you need to change the include from pointing to postgres.h to postgres_fe.h in the ext/pgsql/php_pgsql.h in the php source directory.