Re: Re: Bad column offset? - Mailing list pgsql-general

From Mauricio C. de Oliveira
Subject Re: Re: Bad column offset?
Date
Msg-id 36ADAAED.D0D1B4E2@dt.fee.unicamp.br
Whole thread Raw
List pgsql-general
Hi Paulo!

In your query you have the following select:

>       $result = pg_exec( $pgconn, "select htl.nom_htl from htl where
> htl.des_det_htl='s'" ) or die("Query formatted wrong!");

Everything goes well until you try:

>         $temp = pg_result($result, $i, "htl.nom_htl");
>
> Warning: Bad column offset specified in
> /usr/local/etc/httpd/htdocs/myscript.php3 on line 21

Even though you have requested the column "htl.nom_htl" from the table "htl", an error is generated since the column
labelreturned 
by postgres is simply "nom_htl", hence the bad column offset (label, in this case)! Of course you can change this label
byusing an 
alias. Try replacing the label in the "pg_result" by:

        $temp = pg_result($result, $i, "nom_htl");

This should work. Bye, Mauricio

--
Mauricio Carvalho de Oliveira
mailto:carvalho@dt.fee.unicamp.br
http://www.dt.fee.unicamp.br/~carvalho



pgsql-general by date:

Previous
From: "Juan Rufino Cuervo Soto"
Date:
Subject: General Info
Next
From: Paul Ramsey
Date:
Subject: Using SELECT to get table info.