LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   php postgres connecting needed help (https://www.linuxquestions.org/questions/linux-newbie-8/php-postgres-connecting-needed-help-253504/)

vickr1z 11-11-2004 12:23 AM

php postgres connecting needed help
 
goo day to all.

id like to ask if how can i make a php script to connect on remote postgres server.
let say my localhost was 192.19.0.100 and the remote postgres server host was 192.19.0.101.

any idea? thanks again in advance, and more power!

chris

iluvatar 11-11-2004 01:54 AM

first make sure the postgres server is tcp/ip enabled, second make sure php is postgres enabled, then you can use this php code:
Code:

<?php
$connection = pg_connect("host=192.19.0.101 port=5432 dbname=<database name> user=<user> password=<password>");
?>

all arguments are optional, and have default values wich can be set. check the php documentation on postgresql.

greetz,
.-=~ iluvatar ~=-.

linux_terror 11-11-2004 03:13 AM

just being proactive here--make sure the firewall on the postgres server is allowing connections on port 5432 and if it's behind a router make sure its forwarded.

linux_terror


All times are GMT -5. The time now is 05:36 AM.