Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F1CE476DDB for ; Wed, 18 Dec 2002 17:13:30 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id E7352476B0A for ; Wed, 18 Dec 2002 17:03:22 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gBIM2LJb014436; Wed, 18 Dec 2002 15:02:21 -0700 (MST) Date: Wed, 18 Dec 2002 15:04:01 -0700 (MST) From: "scott.marlowe" To: Thorsten Haude Cc: PostgreSQL PHP ML Subject: Re: pg_fetch_array() In-Reply-To: <20021218203832.GI1604@eumel.yoo.local> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/44 X-Sequence-Number: 1719 On Wed, 18 Dec 2002, Thorsten Haude wrote: > Hi, > > I want to read an unknown number of rows from a select result. I try > this: > - - - Schnipp - - - > $result = pg_exec($dbh, $statement); > $row = 0; > while ($item = pg_fetch_array($result, $row, PGSQL_ASSOC)) > { > doSomething($item); > $row++; > } > - - - Schnapp - - - > > However, I get an error telling me that PHP is "Unable to jump to row > [$nRows + 1] on PostgreSQL result index 3 in [$file] on line [$line] Sorry for the previously not quite right response. Since you are passing in PGSQL_ASSOC you have to supply a row number, do it like this: $stop = pg_num_rows($result); for ($i=0;$i<$stop;$i++){ doSomething($item); }