Jump to content

PHP connecting to Postgres - how can I set a default Host?


Recommended Posts

 

G'day,

 

I am trying to set up a webserver as a backup for our current server. So far its going fine - except for one snag.

 

We use Postgres a LOT - but most of it was written before I arrived, and so our code dosnt have a specfic host=localhost in the pg_connect string.

$connection = pg_connect("dbname=??? port=5432 user=???");

 

This works fine on the old server - and we have a heap of scripts that use it (it would be awefull to try and fix each instance)

 

On the new server it seems to require a host in the string

$connection = pg_connect("host=localhost dbname=??? port=5432 user=???");

 

Is there a way to set it so it uses localhost by default if not specified (as it appear to do in the old server). At the moment all I get is an error saying it cant connect.

 

The error complains that it cant find "/tmp/.s.PGSQL.5432" which isnt on the new server (but is on the old) - but I dont know how to set that up either.

 

Sorry for being such a pain - but any help would be appreciated.

 

Cheers,

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.