if you're running php 3 then you may need to use the "old" version of pg_connect() which is
pg_connect("", "", "", "", "foobardb");
NOT the pg_connect() with one big string. If you're getting an invalid number of parameters error this is probably why. I really suggest you use php4 tho' it's gotta be on apt-get or there should be a deb package out there somewhere (or, hey, you could compile it... not so tough to do).