Thread: Bad column offset ?

Bad column offset ?

From
"Paulo Parola"
Date:
I am porting all my applications from mSQL to PostgreSQL. I am trying to
access the results from a query to PostgreSQL issued from within PHP3.

I connect with no problems to the database, and I can even get the number of
elements returned by my query like below:

   $result = pg_exec( $pgconn, "select ... from ... where ..." ) or
die("Query formatted wrong!");
   $elements = pg_numrows( $result );

But when I try to access some columns inside each row returned, as with the
lines below

line 59     $i=0;
line 60     $temp = pg_result($result, $i, "htl.nom_htl");

I get the following error:

  Warning: Bad column offset specified in
/usr/local/etc/httpd/htdocs/myscript.php3 on line 60

I tried to make '$i=1' initially, but then I get the following error:

  Warning: Unable to jump to row 1 on PostgresSQL result index 3 in
  /usr/local/etc/httpd/htdocs/myscript.php3 on line 60


So how can I retrieve the values returned by my query with PostgreSQL?
What am I doing wrong?

TIA,

Paulo Parola
pparola@brazilinfo.com