Re: [GENERAL] Re: Bad column offset?
Re: [GENERAL] Re: Bad column offset?
От:
"Paulo Parola" <pparola@brazilinfo.com>
Дата:
>> >> I get the following error: >> >> Warning: Bad column offset specified in >> /usr/local/etc/httpd/htdocs/myscript.php3 on line 60 > >The problem is probably with your column labels in the select statement, which you have not provided in your original message. In this case "htl.nom_htl" should be listed in the select statement. Also notice that although PostgreSQL is case insensitive, the PHP function "pg_result" is not. So, if >you have a query like > > $result = pg_exec( $pgconn, "select Test from ..." ) > >you will have the same > > Warning: Bad column offset ... > >if you try > > $temp = pg_result($result, $i, "Test"); > >The correct answer may be obtained with the lowercase column label > > $temp = pg_result($result, $i, "test"); Check out the following test example I have made which gives me the same error. Note that the name of the table is 'htl' in lowercase and the selected field is 'nom_htl', also lowercase. So there is no type mismatch in terms of lowercase/uppercase. Note also that elements are indeed returned from this query. --------------------------------------------- Sorry.\n"; } else { echo "\nConnection OK.
\n"; $result = pg_exec( $pgconn, "select htl.nom_htl from htl where htl.des_det_htl='s'" ) or die("Query formatted wrong!"); $number_of_records = pg_numrows( $result ); echo "Number of elements returned: $number_of_records
"; if ($number_of_records==0) echo "No records matching your criteria were found. "; if ($number_of_records!=0) { $i=0; $temp = pg_result($result, $i, "htl.nom_htl"); echo "
"; ?> --------------------------------------------- The output of this script printed to the screen is the following: --------------------------------------------- Connection OK. Number of elements returned: 63 Warning: Bad column offset specified in /usr/local/etc/httpd/htdocs/myscript.php3 on line 21 Field 'nom_htl' of first element returned: End of page --------------------------------------------- Now, any tips on what's going wrong here? TIA, Paulo Parola pparola@brazilinfo.com
Field 'nom_htl' of first element returned: "; echo "$temp"; } if ( !pg_close( $pgconn ) ) echo "\n"; } echo "
End of page"; echo "