Thread: Connection Problem to DB Table

Connection Problem to DB Table

From
Jeff - Webmaster
Date:
I have an existing postgres DB that is functional. I am trying to make changes to the DB, and I am creating a new test db to play with before moving it over. I am encountering a problem when attempting to execute a SELECT via a php web interface:

Warning: PostgreSQL query failed: ERROR: lookup3: Permission denied. in /var/www/html/harbornet/admin/lookup_street2.php on line 52
An error occured.

The line referenced is:

$result = pg_exec($connect, "SELECT * FROM $tablename WHERE house LIKE '%$newaddress%'");

which refers to:

$connect = pg_connect("dbname=harbornetdb user=harbornet password=HN_pgsql");

I know that I have permissions set incorrectly for the table, but I cannot figure out where my mistake is. The table name is lookup3. The exact same PHP code works for a different table in the same DB by the name of lookup2. I tried the following GRANT statement to no avail:

GRANT all ON lookup3 TO <username>

Any help is much appreciated. Thanks.

Jeff Hunnicutt

Re: Connection Problem to DB Table

From
Tom Allison
Date:
Jeff - Webmaster wrote:
> I have an existing postgres DB that is functional. I am trying to make
> changes to the DB, and I am creating a new test db to play with before
> moving it over. I am encountering a problem when attempting to execute a
> SELECT via a php web interface:
>
> *Warning*: PostgreSQL query failed: ERROR: lookup3: Permission denied.
> in */var/www/html/harbornet/admin/lookup_street2.php* on line *52
> *An error occured.
>
> The line referenced is:
>
> $result = pg_exec($connect, "SELECT * FROM $tablename WHERE house LIKE
> '%$newaddress%'");
>
> which refers to:
>
> $connect = pg_connect("dbname=harbornetdb user=harbornet
> password=HN_pgsql");
>
> I know that I have permissions set incorrectly for the table, but I
> cannot figure out where my mistake is. The table name is lookup3. The
> exact same PHP code works for a different table in the same DB by the
> name of lookup2. I tried the following GRANT statement to no avail:
>
> GRANT all ON lookup3 TO <username>
>
> Any help is much appreciated. Thanks.
>
> Jeff Hunnicutt

Take it out of PHP and run it from psql.
Any chance that you don't have permissions to access the database
according to pg_hba.conf?