fbpx

How to Fix PGSQL query failed

Steps to fix the error Pgsql query failed

If you receive the following error while trying to access a page using postgresql database credentials, you can follow the steps listed below to fix this.

Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission denied for relation in /home/username/public_html/123.php 
Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /home/username/public_html/123.php

Step 1: Open the postgresql configuration file.

vi /var/lib/pgsql/data/pg_hba.conf

Scroll down and check for the following lines.

local all all md5
host all all 127.0.0.1 255.255.255.255 md5

 Just change it as given below and save the file.

 local all all md5
 host all all 127.0.0.1 255.255.255.255 password

Step 2: Restart Postgresql.

/etc/rc.d/init.d/postgresql restart

Done!!!

Leave a Reply

Your email address will not be published. Required fields are marked *