first steps in PhP and PostgreSQL
X-No-Archive: true
Hi,
I'm sure that it's a typo or something, but as I'm getting into PhP and PostgreSQL for the first time, I can't be sure.
I have a db, called 'cdi' ..
A 'SELECT * FROM stock;' gets me this in psql ..
cdi=> SELECT * from stock ;
-[ RECORD 1 ]-+-------------------------------
stock_ids | 1
isbn_no | 10101010
code_livre | 23455
titre | toto goes to Hollywood
editeur | editions toto
collection | collection toto
auteur_nom | smith
auteur_prenom | john
matiere | ang
media_type | li
-[ RECORD 2 ]-+-------------------------------
stock_ids | 2
isbn_no | 10536278
code_livre | 24874
titre | toto comes back from Hollywood
editeur | editions baba
collection | collection toto
auteur_nom | martin
auteur_prenom | peter
matiere | fre
media_type | dvd
So the db is populated. I now do this in a file called base.php ..
<?php
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."<br />";
echo "blah ".$row['code_livre']."<br />";
}
?>
I copy that file to my apache server, in php_experimental/base.php and access it via a browser.
I don't get an error message. I instead get a blank page.
Your advice would be welcome.
D.
---------------------------------
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions ! Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses.
In response to Desmond Coughlan <coughlandesmond@yahoo.fr>:
X-No-Archive: true
X-WTF: huh?
[snip]
I copy that file to my apache server, in php_experimental/base.php
and access it via a browser.I don't get an error message. I instead get a blank page.
Check the applicable php.ini for where error messages are being sent to.
It's typical on production servers to configure PHP to only send errors
to syslog, or a file, which usually means they end up in httpd-error.log.
When developing, it's usually more convenient to have errors sent to the
browser, which is what it seems you were expecting.
--
Bill Moran
Collaborative Fusion Inc.
Desmond Coughlan wrote:
<?php
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
Firstly, rewrite this as
$sql = "SELECT * FROM stock";
$res = pg_query($sql);
echo "pg_query($sql) = $res<br>";
echo "num rows = ".pg_num_rows($res)."<br>";
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."<br />";
echo "blah ".$row['code_livre']."<br />";
}
?>
Now you'll know what the return-code of pg_query was as well as how manu
rows it returned. Does that help at all?
--
Richard Huxton
Archonet Ltd
# coughlandesmond@yahoo.fr / 2006-11-06 15:05:25 +0100:
I'm sure that it's a typo or something, but as I'm getting into PhP
and PostgreSQL for the first time, I can't be sure.
<?php
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."<br />";
echo "blah ".$row['code_livre']."<br />";
}
?>I copy that file to my apache server, in php_experimental/base.php
and access it via a browser.I don't get an error message. I instead get a blank page.
Check apache's error log. If you can't figure it out then, better
place to ask further questions would be php-general@lists.php.net.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
Have you checked your webserver error logs?
On Mon, 6 Nov 2006, Desmond Coughlan wrote:
X-No-Archive: true
Hi,
I'm sure that it's a typo or something, but as I'm getting into PhP and PostgreSQL for the first time, I can't be sure.I have a db, called 'cdi' ..
A 'SELECT * FROM stock;' gets me this in psql ..
cdi=> SELECT * from stock ;
-[ RECORD 1 ]-+-------------------------------
stock_ids | 1
isbn_no | 10101010
code_livre | 23455
titre | toto goes to Hollywood
editeur | editions toto
collection | collection toto
auteur_nom | smith
auteur_prenom | john
matiere | ang
media_type | li
-[ RECORD 2 ]-+-------------------------------
stock_ids | 2
isbn_no | 10536278
code_livre | 24874
titre | toto comes back from Hollywood
editeur | editions baba
collection | collection toto
auteur_nom | martin
auteur_prenom | peter
matiere | fre
media_type | dvdSo the db is populated. I now do this in a file called base.php ..
<?php
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."<br />";
echo "blah ".$row['code_livre']."<br />";
}
?>I copy that file to my apache server, in php_experimental/base.php and access it via a browser.
I don't get an error message. I instead get a blank page.
Your advice would be welcome.
D.
---------------------------------
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions ! Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses.
From pgsql-general-owner@postgresql.org Mon Nov 6 13:20:33 2006
Received: from localhost (wm.hub.org [200.46.204.128])
by postgresql.org (Postfix) with ESMTP id B2E4F9FA136
for <pgsql-general-postgresql.org@postgresql.org>; Mon, 6 Nov 2006 13:20:32 -0400 (AST)
Received: from postgresql.org ([200.46.204.71])
by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024)
with ESMTP id 14382-01 for <pgsql-general-postgresql.org@postgresql.org>;
Mon, 6 Nov 2006 17:20:26 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-
Received: from mx01.bfk.de (mx01.bfk.de [193.227.124.2])
by postgresql.org (Postfix) with ESMTP id BD69C9F9806
for <pgsql-general@postgresql.org>; Mon, 6 Nov 2006 13:20:19 -0400 (AST)
Received: from [10.119.110.2] (helo=mx00.int.bfk.de)
by mx01.bfk.de with esmtp id 1Gh88r-0002mS-A6; Mon, 06 Nov 2006 18:20:13 +0100
Received: from fweimer by bfk.de with local id 1Gh88r-00027m-60; Mon, 06 Nov 2006 18:20:13 +0100
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-general@postgresql.org
Subject: Re: DISTINCT is not quite distinct
References: <82lkmoy979.fsf@mid.bfk.de> <454F47F7.6090108@archonet.com>
From: Florian Weimer <fweimer@bfk.de>
Date: Mon, 06 Nov 2006 18:20:13 +0100
In-Reply-To: <454F47F7.6090108@archonet.com> (Richard Huxton's message of "Mon, 06 Nov 2006 14:34:31 +0000")
Message-ID: <827iy8xzjm.fsf@mid.bfk.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Virus-Scanned: Maia Mailguard 1.0.1
X-Archive-Number: 200611/324
X-Sequence-Number: 103420
* Richard Huxton:
I take it SELECT DISTINCT bar... shows the same problem?
SELECT bar FROM baz does *not* show the duplicate row.
If so, can you do:
SELECT OID,xmin,cmin,xmax,cmax,bar FROM baz
WHERE bar =3D <something with duplicates>
Even if I force a complete index scan, I get xmin =3D 1007617 for both
rows, the others are zero. The table hasn't got OIDs.
--=20
Florian Weimer <fweimer@bfk.de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstra=DFe 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99
X-No-Archive: true
Yep...
192.168.0.254 - - [07/Nov/2006:10:12:57 +0100] "GET /php_experimental/base.php HTTP/1.1" 200 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
D.
Ben <bench@silentmedia.com> a �crit :
Have you checked your webserver error logs?
On Mon, 6 Nov 2006, Desmond Coughlan wrote:
X-No-Archive: true
Hi,
I'm sure that it's a typo or something, but as I'm getting into PhP and PostgreSQL for the first time, I can't be sure.I have a db, called 'cdi' ..
A 'SELECT * FROM stock;' gets me this in psql ..
cdi=> SELECT * from stock ;
-[ RECORD 1 ]-+-------------------------------
stock_ids | 1
isbn_no | 10101010
code_livre | 23455
titre | toto goes to Hollywood
editeur | editions toto
collection | collection toto
auteur_nom | smith
auteur_prenom | john
matiere | ang
media_type | li
-[ RECORD 2 ]-+-------------------------------
stock_ids | 2
isbn_no | 10536278
code_livre | 24874
titre | toto comes back from Hollywood
editeur | editions baba
collection | collection toto
auteur_nom | martin
auteur_prenom | peter
matiere | fre
media_type | dvdSo the db is populated. I now do this in a file called base.php ..
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."
";
echo "blah ".$row['code_livre']."
";
}
?>I copy that file to my apache server, in php_experimental/base.php and access it via a browser.
I don't get an error message. I instead get a blank page.
Your advice would be welcome.
D.
---------------------------------
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions ! Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses.
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
--
Des Coughlan
coughlandesmond@yahoo.fr
"Un client de plus, c'est un relou de plus..."
---------------------------------
Yahoo! Mail r�invente le mail ! D�couvrez le nouveau Yahoo! Mail et son interface r�volutionnaire.
No, that's the access log. Check the error log.
On Tue, 7 Nov 2006, Desmond Coughlan wrote:
X-No-Archive: true
Yep...
192.168.0.254 - - [07/Nov/2006:10:12:57 +0100] "GET /php_experimental/base.php HTTP/1.1" 200 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
D.
Ben <bench@silentmedia.com> a �crit :
Have you checked your webserver error logs?On Mon, 6 Nov 2006, Desmond Coughlan wrote:
X-No-Archive: true
Hi,
I'm sure that it's a typo or something, but as I'm getting into PhP and PostgreSQL for the first time, I can't be sure.I have a db, called 'cdi' ..
A 'SELECT * FROM stock;' gets me this in psql ..
cdi=> SELECT * from stock ;
-[ RECORD 1 ]-+-------------------------------
stock_ids | 1
isbn_no | 10101010
code_livre | 23455
titre | toto goes to Hollywood
editeur | editions toto
collection | collection toto
auteur_nom | smith
auteur_prenom | john
matiere | ang
media_type | li
-[ RECORD 2 ]-+-------------------------------
stock_ids | 2
isbn_no | 10536278
code_livre | 24874
titre | toto comes back from Hollywood
editeur | editions baba
collection | collection toto
auteur_nom | martin
auteur_prenom | peter
matiere | fre
media_type | dvdSo the db is populated. I now do this in a file called base.php ..
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."";
echo "blah ".$row['code_livre']."
";
}
?>I copy that file to my apache server, in php_experimental/base.php and access it via a browser.
I don't get an error message. I instead get a blank page.
Your advice would be welcome.
D.
---------------------------------
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions ! Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses.---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly--
Des Coughlan
coughlandesmond@yahoo.fr"Un client de plus, c'est un relou de plus..."
---------------------------------
Yahoo! Mail r�invente le mail ! D�couvrez le nouveau Yahoo! Mail et son interface r�volutionnaire.
From pgsql-general-owner@postgresql.org Tue Nov 7 14:00:36 2006
Received: from localhost (pluto.hub.org [200.46.204.4])
by postgresql.org (Postfix) with ESMTP id 59BCC9FA173
for <pgsql-general-postgresql.org@postgresql.org>; Tue, 7 Nov 2006 14:00:35 -0400 (AST)
Received: from postgresql.org ([200.46.204.71])
by localhost (mx1.hub.org [200.46.204.4]) (amavisd-new, port 10024)
with ESMTP id 68541-09 for <pgsql-general-postgresql.org@postgresql.org>;
Tue, 7 Nov 2006 14:00:32 -0400 (AST)
X-Greylist: domain auto-whitelisted by SQLgrey-
Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.225])
by postgresql.org (Postfix) with ESMTP id 272C39FA14D
for <pgsql-general@postgresql.org>; Tue, 7 Nov 2006 14:00:29 -0400 (AST)
Received: by wr-out-0506.google.com with SMTP id i31so402535wra
for <pgsql-general@postgresql.org>; Tue, 07 Nov 2006 10:00:29 -0800 (PST)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=beta; d=gmail.com;
h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
b=NbYJUnl9Ri4p7VvPyjX4HHoLSYy/VvIqw+szjNuU69IYMIv2rbEXR8JYoO5uaCuRc6f3f2jaftaq79PP7nKqkboxRZlP68PgJEZJ8isjsiO5HGhaxeBOfJI8kdnlEhInl6Wri4VrbSG7wc6xneMTDwo13pqH+D1Fw+kPhKuhmoo=
Received: by 10.65.176.7 with SMTP id d7mr8226807qbp.1162922427978;
Tue, 07 Nov 2006 10:00:27 -0800 (PST)
Received: by 10.65.212.16 with HTTP; Tue, 7 Nov 2006 10:00:27 -0800 (PST)
Message-ID: <bc63ad820611071000r76416ac9yd3237c411ebced91@mail.gmail.com>
Date: Tue, 7 Nov 2006 16:00:27 -0200
From: "=?ISO-8859-1?Q?William_Leite_Ara=FAjo?=" <william.bh@gmail.com>
To: "Alain Roger" <raf.news@gmail.com>
Subject: Re: FOR ... IN
Cc: pgsql-general@postgresql.org
In-Reply-To: <75645bbb0611070918j27a83430oab11cc7a76d5aad2@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_10487_10731000.1162922427839"
References: <75645bbb0611061139q73727900na9239de37c4e5a6a@mail.gmail.com>
<bc63ad820611070229v59286d05n7db70c7039262a93@mail.gmail.com>
<75645bbb0611070918j27a83430oab11cc7a76d5aad2@mail.gmail.com>
X-Virus-Scanned: Maia Mailguard 1.0.1
X-Archive-Number: 200611/380
X-Sequence-Number: 103476
------=_Part_10487_10731000.1162922427839
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
2006/11/7, Alain Roger <raf.news@gmail.com>:
but there is already a RETURN NEXT res;
so what will be the point of this RETURN after the END LOOP; ?
http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.h=
tml
--=20
William Leite Ara=FAjo
------=_Part_10487_10731000.1162922427839
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
2006/11/7, Alain Roger <<a href=3D"mailto:raf.news@gmail.com">raf.news@g=
mail.com</a>>:<div><span class=3D"gmail_quote"></span><blockquote class=
=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); margin=
: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
but there is already a RETURN NEXT res;<br>so what will be the point of thi=
s RETURN after the END LOOP; ?</blockquote><div><br><a href=3D"http://www.p=
ostgresql.org/docs/8.1/interactive/plpgsql-control-structures.html">http://=
www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html
</a><br><br><br></div></div><br clear=3D"all"><br>-- <br>William Leite Ara=
=FAjo<br>
------=_Part_10487_10731000.1162922427839--
X-No-Archive: true
Ah...
[Wed Nov 08 09:32:56 2006] [error] [client 192.168.0.254] PHP Fatal error: Call to undefined function: pg_connect() in /usr/local/www/data/php_experimental/base.php on line 6
Ben <bench@silentmedia.com> a �crit :
No, that's the access log. Check the error log.
On Tue, 7 Nov 2006, Desmond Coughlan wrote:
X-No-Archive: true
Yep...
192.168.0.254 - - [07/Nov/2006:10:12:57 +0100] "GET /php_experimental/base.php HTTP/1.1" 200 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
D.
Ben a �crit :
Have you checked your webserver error logs?On Mon, 6 Nov 2006, Desmond Coughlan wrote:
X-No-Archive: true
Hi,
I'm sure that it's a typo or something, but as I'm getting into PhP and PostgreSQL for the first time, I can't be sure.I have a db, called 'cdi' ..
A 'SELECT * FROM stock;' gets me this in psql ..
cdi=> SELECT * from stock ;
-[ RECORD 1 ]-+-------------------------------
stock_ids | 1
isbn_no | 10101010
code_livre | 23455
titre | toto goes to Hollywood
editeur | editions toto
collection | collection toto
auteur_nom | smith
auteur_prenom | john
matiere | ang
media_type | li
-[ RECORD 2 ]-+-------------------------------
stock_ids | 2
isbn_no | 10536278
code_livre | 24874
titre | toto comes back from Hollywood
editeur | editions baba
collection | collection toto
auteur_nom | martin
auteur_prenom | peter
matiere | fre
media_type | dvdSo the db is populated. I now do this in a file called base.php ..
pg_connect ("dbname=cdi user=cdi password=toto") or die
("Couldn't Connect: ".pg_last_error());
$query="SELECT * FROM stock";
$query=pg_query($query);
// start the output
while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
echo "Title: ".$row['isbn_no']."";
echo "blah ".$row['code_livre']."
";
}
?>I copy that file to my apache server, in php_experimental/base.php and access it via a browser.
I don't get an error message. I instead get a blank page.
Your advice would be welcome.
D.
---------------------------------
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions ! Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses.---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly--
Des Coughlan
coughlandesmond@yahoo.fr"Un client de plus, c'est un relou de plus..."
---------------------------------
Yahoo! Mail r�invente le mail ! D�couvrez le nouveau Yahoo! Mail et son interface r�volutionnaire.
---------------------------------
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions ! Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses.