Archive for the tag 'Pgsql'

SBDavid

Pgsql query failed

Pgsql query failed

If you are getting the error as follows.

Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission denied for relation cg_ref_codes in /home/user/public_html/xxx.php on line 48
Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /home/user/public_html/xxxx.php on line 50

Resolution

1. Open the pgsql configuration file.

vi /var/lib/pgsql/data/pg_hba.conf
local all all md5
host all all 127.0.0.1 255.255.255.255 md5

The file need to change as follows
local all all md5
host all all 127.0.0.1 255.255.255.255 password

2. Save the file and restart pgsql.

/etc/init.d/postgresql stop
/etc/init.d/postgresql start