Jump to content

Recommended Posts

Posted

I have the following configuration to connect to the database:

 

$db_username = 'user=myuser';
$db_password = 'password=mypass';
$db_name = 'dbname=test';
$db_host = 'host=localhost';

$db = pg_connect("$db_host $db_username $db_password $db_name");
	
    $query = "SELECT * FROM cities";
    $result = pg_query($query);
    if (!$result) {
	    echo "Problem with query " . $query . "<br/>";
	    echo pg_last_error();
	    exit();
    }
  
   $myrow = pg_fetch_assoc($result);
    $city = $myrow[city];
    echo $city;

 

The previous code works and it prints the name of the city in the table cities.

 

Now If I try with the same but another table(Menu) which also have the field city

 

I get the following error:

 

Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission denied for relation menu in /home1/user/public_html/index.php on line 9

Problem with query SELECT * FROM menu

ERROR: permission denied for relation menu

 

Both tables are under the same database (test) which was created by the same user. I don't know if I need to grant access to each table to the user and how or why am I getting this error. (When I run this in my computer it works but once I uploaded to the web that the error I'm getting)

 

Any help would be highly appreciated.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...