Error connecting BD postgres with PHP

Asked

Viewed 65 times

0

I have Postgres 9.3 installed on a Windows server 2012. I need to collect BD information for a website. I’ve already set up the network router forwarding port 5432.

On 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 the pgAdminIII to the database.

On the site, using php I tried to call 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 'Server connection failure'. Connecting to a local website BD works. I don’t know if it’s relevant but the site is php 5.4 and I also tried 5.6.

Anyone can help?

  • By remote pc you connect using this address host=xxxxx.no-ip.net port=5432 ?

  • Yes. I use the same data

1 answer

2

I’ve already figured it out. Stay here for anyone who has similar problems. The host server was blocking the output. I had to ask for permission to connect.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.