I can connect to my database by running php via the bash:
php -r '$link=@pg_connect("host=fakehost.edu port=5432 dbname=db user=user password=totallynotthepassword");if($link){echo "connected";} else { echo "no dice";}'
This results in a very happy "connected"
However, when I have the exact same PHP in a file served by Apache and go to that page, I get a very sad: "no dice"
Here is the code from the php file:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
$link=@pg_connect("host=fakehost.edu port=5432 dbname=db user=user password=totallynotthepassword");if($link){echo "connected";} else { echo "no dice";}
?>
</body>
</html>
I thought it had to do with the apache user, but i just tested the same code su'ed to that user and it connected.