pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Accessing the database
3+ messages / 3 participants
[nested] [flat]

* Accessing the database
@ 2000-06-02 11:05 Pragati Sagar <pragatis@sapientinfotech.com>
  2000-06-02 15:19 ` Re: Accessing the database Jan T. Kim <kim@mpiz-koeln.mpg.de>
  2000-06-02 15:34 ` Re: Accessing the database Daryl Herzmann <akrherz@iastate.edu>
  0 siblings, 2 replies; 3+ messages in thread

From: Pragati Sagar @ 2000-06-02 11:05 UTC (permalink / raw)
  To: pgsql-admin

Hi!
I connecting the postgreSQL database through the following code:

<?
$conn=pg_connect("<IP address>","<port>","","","<database>");
$index=pg_exec($conn,"select * from table1");
?>

On execution of this code from the browser, following error appears :

Warning: PostgresSQL query failed: ERROR: table1: Permission denied. in
/home/httpd/html/script.php3 on line 8

Where am I going wrong? Does the code have a problem or there is something
wrong with the permissions.
Please help me out.

Thanks
Pragati




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Accessing the database
  2000-06-02 11:05 Accessing the database Pragati Sagar <pragatis@sapientinfotech.com>
@ 2000-06-02 15:19 ` Jan T. Kim <kim@mpiz-koeln.mpg.de>
  1 sibling, 0 replies; 3+ messages in thread

From: Jan T. Kim @ 2000-06-02 15:19 UTC (permalink / raw)
  To: Pragati Sagar <pragatis@sapientinfotech.com>; +Cc: pgsql-admin


On Fri, Jun 02, 2000 at 04:35:29PM +0530, Pragati Sagar wrote:
> Hi!
> I connecting the postgreSQL database through the following code:
> 
> <?
> $conn=pg_connect("<IP address>","<port>","","","<database>");
> $index=pg_exec($conn,"select * from table1");
> ?>
> 
> On execution of this code from the browser, following error appears :
> 
> Warning: PostgresSQL query failed: ERROR: table1: Permission denied. in
> /home/httpd/html/script.php3 on line 8
> 
> Where am I going wrong? Does the code have a problem or there is something
> wrong with the permissions.

A quick guess: Maybe you have not created a postgres user called "httpd" (or
"nobody", "daemon" etc., depending on your operating system). PHP scripts
run under the UID of the web server, which usually is not the same as
your personal account.

So, you can either create a httpd user in postgres, or alternatively, I
think that pg_connect() in PHP also offers a way to specify your username
and password as parameters (check out the PHP docs on the PostgreSQL
functions for details).

HTH.

Greetinx & have a nice weekend,
Jan
-- 
 +- Jan T. Kim -------------------------------------------------------+
 |             email: kim@mpiz-koeln.mpg.de                           |
 |             WWW:   http://www.mpiz-koeln.mpg.de/~kim/              |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Accessing the database
  2000-06-02 11:05 Accessing the database Pragati Sagar <pragatis@sapientinfotech.com>
@ 2000-06-02 15:34 ` Daryl Herzmann <akrherz@iastate.edu>
  1 sibling, 0 replies; 3+ messages in thread

From: Daryl Herzmann @ 2000-06-02 15:34 UTC (permalink / raw)
  To: Pragati Sagar <pragatis@sapientinfotech.com>; +Cc: pgsql-admin

Pragati,
	I am assuming that your webserver is running as user "nobody".  If
that is the case, then you need to make sure that the user "nobody" can
access the table.
	If your scripts only do selects on the table, then this command
would do the trick

GRANT SELECT on table1 to nobody;

	Check the docs on the GRANT command, you may need to give user
nobody more provledges than SELECT, if your scripts are doing other things
than SELECT...

http://www.postgresql.org/docs/user/sql-grant.htm

	Also, make sure that the user nobody exists.  You may need to add
this user too from a postgres superuser account...

http://www.postgresql.org/docs/user/sql-createuser.htm

Hope this helps,
	Daryl


On Fri, 2 Jun 2000, Pragati Sagar wrote:

~|Hi!
~|I connecting the postgreSQL database through the following code:
~|
~|<?
~|$conn=pg_connect("<IP address>","<port>","","","<database>");
~|$index=pg_exec($conn,"select * from table1");
~|?>
~|
~|On execution of this code from the browser, following error appears :
~|
~|Warning: PostgresSQL query failed: ERROR: table1: Permission denied. in
~|/home/httpd/html/script.php3 on line 8
~|
~|Where am I going wrong? Does the code have a problem or there is something
~|wrong with the permissions.
~|Please help me out.
~|
~|Thanks
~|Pragati
~|





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2000-06-02 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-02 11:05 Accessing the database Pragati Sagar <pragatis@sapientinfotech.com>
2000-06-02 15:19 ` Jan T. Kim <kim@mpiz-koeln.mpg.de>
2000-06-02 15:34 ` Daryl Herzmann <akrherz@iastate.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox