Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3DA27476DC5 for ; Wed, 18 Dec 2002 17:09:56 -0500 (EST) Received: from post.webmailer.de (natsmtp00.webmailer.de [192.67.198.74]) by postgresql.org (Postfix) with ESMTP id 9036E476DEC for ; Wed, 18 Dec 2002 16:56:58 -0500 (EST) Received: from eumel.yoo.local (pD952C4AE.dip.t-dialin.net [217.82.196.174]) by post.webmailer.de (8.9.3/8.8.7) with ESMTP id WAA04548 for ; Wed, 18 Dec 2002 22:56:43 +0100 (MET) Received: by eumel.yoo.local (Postfix on SuSE Linux 7.2 (i386), from userid 500) id E91993C1F0; Wed, 18 Dec 2002 23:03:29 +0100 (CET) Date: Wed, 18 Dec 2002 23:03:29 +0100 From: Thorsten Haude To: pgsql-php@postgresql.org Subject: Re: pg_fetch_array() Message-ID: <20021218220329.GK1604@eumel.yoo.local> Mail-Followup-To: pgsql-php@postgresql.org References: <20021218203832.GI1604@eumel.yoo.local> <20021218131228.13eb6d7d.waddell@caravan.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021218131228.13eb6d7d.waddell@caravan.com> X-Warning: Email may contain unsmilyfied humor and/or satire. Keywords: Eine Botschaft for =?iso-8859-1?Q?Kuriere?= =?iso-8859-1?Q?=3A_Drogen_t=F6ten!?= Organization: Ministry of Information, Department of Information Adjustments User-Agent: Mutt/1.5.1i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/43 X-Sequence-Number: 1718 Hi, * Harry Waddell [2002-12-18 22:12]: >Thorsten Haude wrote: >> - - - Schnipp - - - >> $result = pg_exec($dbh, $statement); >> $row = 0; >> while ($item = pg_fetch_array($result, $row, PGSQL_ASSOC)) >> { >> doSomething($item); >> $row++; >> } >> - - - Schnapp - - - >> >> What do I miss? A clue-by-four, it seems. >your using a while loop to process each result, but the last one which you >expect to return NULL/failure has to evaluate pg_fetch_array first with the >non-existent row index. Of course. The only excuse I have is that I misread the documentation in a really stupid way. (Not much of an excuse, is it?) >You may be able to prepend @ to pg_fetch_array to supress the warning >[you should check that $result is not NULL also], but I'd recommend >using pg_NumRows and a for-loop instead. Sure, I'll do that. I don't want to suppress anyone, much less warnings. Thanks for your patience. Thorsten -- Endorsing products is the American way of expressing individuality. - Calvin