pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPostgreSQL and PHP
3+ messages / 3 participants
[nested] [flat]
* PostgreSQL and PHP
@ 2000-02-24 11:06 James Macken <jmac@nemesis.com.au>
2000-02-24 11:37 ` Re: [SQL] PostgreSQL and PHP Stefano Brozzi <sbrozzi@bci.it>
2000-02-24 12:00 ` Re: [SQL] PostgreSQL and PHP Giampiero Raschetti <giampiero.raschetti@popso.it>
0 siblings, 2 replies; 3+ messages in thread
From: James Macken @ 2000-02-24 11:06 UTC (permalink / raw)
To: pgsql-sql@hub.org
To those of you who use PHP with PostgreSQL,
I'm trying to do a simple select inside a ".php3" script. The php3 script
simply says something like (the linux machine is not turned on so I can't
grab it exactly):
<?php
$database = pg_connect("","","","mydb");
pg_exec($database, "select * from mytable");
echo "whatever"
?>
and all I get is (in the resulting web page):
whatever
In other words, it doesn't print out on the web page the query that I just
made. Now have added the "nobody" web user to the list of authorised people
and I have granted permission for nobody to do anything he likes to mydb.
Other things work however such as the echo command above and the "info" php
command.
Any ideas?
James
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] PostgreSQL and PHP
2000-02-24 11:06 PostgreSQL and PHP James Macken <jmac@nemesis.com.au>
@ 2000-02-24 11:37 ` Stefano Brozzi <sbrozzi@bci.it>
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Brozzi @ 2000-02-24 11:37 UTC (permalink / raw)
To: James Macken <jmac@nemesis.com.au>; +Cc: pgsql-sql@hub.org
James Macken wrote:
>
> To those of you who use PHP with PostgreSQL,
>
> I'm trying to do a simple select inside a ".php3" script. The php3 script
> simply says something like (the linux machine is not turned on so I can't
> grab it exactly):
>
> <?php
> $database = pg_connect("","","","mydb");
> pg_exec($database, "select * from mytable");
> echo "whatever"
> ?>
>
> and all I get is (in the resulting web page):
>
> whatever
>
I guess you have more lines in your php script,
have you lines like these:
$result = pg_Exec ($database, $sqlStr);
if (!$result) {
echo "An error occured.\n";
exit;
}
for($i=0; $i<pg_NumRows($result); $i++)
{
$row = pg_Fetch_array($result, $i);
echo $row[1];
}
???
if not, please RTFM.
if you have written down these lines (or cut&pasted from the manual),
and still it doesn't work, feel free to contact me.
stefano
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] PostgreSQL and PHP
2000-02-24 11:06 PostgreSQL and PHP James Macken <jmac@nemesis.com.au>
@ 2000-02-24 12:00 ` Giampiero Raschetti <giampiero.raschetti@popso.it>
1 sibling, 0 replies; 3+ messages in thread
From: Giampiero Raschetti @ 2000-02-24 12:00 UTC (permalink / raw)
To: James Macken <jmac@nemesis.com.au>; pgsql-sql@hub.org
Did you really read the manual ?
From the php postgresSQL manual (pg_fetch_array)
Example 1. PostgreSQL fetch array
<?php
$conn = pg_pconnect("","","","","publisher");
if (!$conn) {
echo "An error occured.\n";
exit;
}
$result = pg_Exec ($conn, "SELECT * FROM authors");
if (!$result) {
echo "An error occured.\n";
exit;
}
$arr = pg_fetch_array ($result, 0);
echo $arr[0] . " <- array\n";
$arr = pg_fetch_array ($result, 1);
echo $arr["author"] . " <- array\n";
?>
Prev
James Macken wrote:
>
> To those of you who use PHP with PostgreSQL,
>
> I'm trying to do a simple select inside a ".php3" script. The php3 script
> simply says something like (the linux machine is not turned on so I can't
> grab it exactly):
>
> <?php
> $database = pg_connect("","","","mydb");
> pg_exec($database, "select * from mytable");
> echo "whatever"
> ?>
>
> and all I get is (in the resulting web page):
>
> whatever
>
> In other words, it doesn't print out on the web page the query that I just
> made. Now have added the "nobody" web user to the list of authorised people
> and I have granted permission for nobody to do anything he likes to mydb.
>
> Other things work however such as the echo command above and the "info" php
> command.
>
> Any ideas?
>
> James
>
> ************
--
Best Regards
----------------------------
Ing. Giampiero Raschetti
Sistemi Innovativi
Banca Popolare di Sondrio
----------------------------
Attachments:
smime.p7s (application/x-pkcs7-signature, 1.9K) download
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-02-24 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-02-24 11:06 PostgreSQL and PHP James Macken <jmac@nemesis.com.au>
2000-02-24 11:37 ` Stefano Brozzi <sbrozzi@bci.it>
2000-02-24 12:00 ` Giampiero Raschetti <giampiero.raschetti@popso.it>
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