Jump to content

Accessing My Postgresql Table (Permissions?)


samuvk

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...