Re:Trying to SELECT via web server using PHP

From: Bill Sneed <bsneed(at)mint(dot)net>
To: pgsql-general(at)hub(dot)org
Subject: Re:Trying to SELECT via web server using PHP
Date: 1999-11-20 13:32:31
Message-ID: 3836A2EF.AAE7CB46@mint.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Greetings,
>
> I've got pgsql running fine from the command line, but I'm having =
> problems using PHP to do a select...suggestions?
>
> <html>
> <body>
> <?php
> $conn =3D pg_Connect("host=3Dlocalhost port=3D5432 dbname=3Dcustomers");
> $result =3D pg_exec($conn, 'select * from employees');
> echo $result;
> pg_exec ($database, "commit");
> pg_exec ($database, "end");
> ?>
> </body>
> </html>
>
> results in:
> Warning: PostgresSQL query failed: ERROR: employees: Permission denied. =
> in /home/httpd/html/connect2.php3 on line 6
>
> Warning: 0 is not a PostgresSQL link index in =
> /home/httpd/html/connect2.php3 on line 8
>
> Warning: 0 is not a PostgresSQL link index in =
> /home/httpd/html/connect2.php3 on line 9
>
> If I change the host, the thing really blows a gasket.
>

There may be a couple of things wrong here:

(1) You've granted "nobody" read rights to the table(s)? Don't forget
that user "nobody" is default user of Apache -- and perhaps other
Web servers as well.

(2) My pg_connect statements are all of the form:
pg_connect("localhost","5432","","","library");
Some of the parameters can be omitted but I believe the quotes &
commas are needed.

(3) You are "echoing" your output into a table with a "while"? If not
all you'll get --at best-- is one entry.

Hope that helps .....

....Bill Sneed, Prospect, Maine....

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 1999-11-20 14:26:03 Re: [GENERAL] Re:Trying to SELECT via web server using PHP
Previous Message Duncan Kinder 1999-11-19 23:32:32 postgresadmin difficulty