I have Postgres 9.3 installed on a Windows server 2012. I need to collect DB information for consultation on a website. I already configured the network router forwarding port 5432.
In pg_hba I changed the line: host all all 0.0.0.0/0 md5
In postgresql I put the line: listen_addresses = '*'
On a remote pc I can connect pgAdminIII to the database.
In the site, using php I tried to connect using:
$liga = "host=xxxxx.no-ip.net port=5432 dbname=gwrcsg01f1 user=postgres password=xxxxxxx";
$conn = pg_connect($liga) or die('Falha de ligacao ao servidor');
$result = pg_query($conn , "SELECT * FROM clientes;");
$registo = pg_fetch_array($result);
pg_close();
I always get 'Failed to connect to the server'. If connecting to a local DB of the site works. I do not know if it is relevant but on the site is php 5.4 and I also tried 5.6.
Can anyone help?