Error connecting postgres DB with PHP

0

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?

    
asked by anonymous 27.09.2017 / 10:30

1 answer

2

I've already figured it out. It stays here for those who have similar problems. The hosting server was blocking the exit. I had to request that I authorize the call.

    
27.09.2017 / 12:30