From angelo.rigo@globo.com Thu Aug 8 16:50:22 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DB92847546C for ; Thu, 8 Aug 2002 12:50:22 -0400 (EDT) Received: from nplex.globo.com (email.globo.com [200.208.9.53]) by postgresql.org (Postfix) with ESMTP id E30D5475452 for ; Thu, 8 Aug 2002 12:50:21 -0400 (EDT) Received: from [200.219.69.253] by nplex.globo.com with HTTP; Thu, 8 Aug 2002 13:50:30 -0300 Date: Thu, 8 Aug 2002 13:50:30 -0300 Message-ID: <3D3EEC5F00049E81@riosf05.globoi.com> From: angelo.rigo@globo.com Subject: pg_fetch_array problem To: pgsql-php@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/24 X-Sequence-Number: 1369 Hi i am trying to build previous and next links from a table selection, the code below stops working at the line which says : while ($dados =3D pg_fetch_array($limite)) { $nome =3D $dados["nome"]; echo "Nome: $nome
"; the warning says: Wrong parameter count for pg_fetch_array() i get this code from a php mysql and try to adapt to my needs, is that any parameter wrong? wich can be? "; } // agora vamos criar os bot=F5es "Anterior e pr=F3ximo" $anterior =3D $pc -1; $proximo =3D $pc +1; if ($pc>1) { echo " <- Anterior "; } echo "|"; if ($pc<$tp) { echo " Pr=F3xima ->"; } ?> ________________________________________ A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com= .br. From dbrown@centennialwines.com Thu Aug 8 17:00:12 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A8BD047546C for ; Thu, 8 Aug 2002 13:00:12 -0400 (EDT) Received: from enterprise.centliq.com (adsl-65-71-224-185.dsl.rcsntx.swbell.net [65.71.224.185]) by postgresql.org (Postfix) with ESMTP id B9934475452 for ; Thu, 8 Aug 2002 13:00:11 -0400 (EDT) Received: from centennialwines.com (unknown [192.168.1.2]) by enterprise.centliq.com (Postfix) with ESMTP id A4CB7FF009; Thu, 8 Aug 2002 10:56:35 -0500 (CDT) Message-ID: <3D52A2EA.6040204@centennialwines.com> Date: Thu, 08 Aug 2002 11:57:14 -0500 From: "David C. Brown" User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 To: angelo.rigo@globo.com Cc: pgsql-php@postgresql.org Subject: Re: pg_fetch_array problem References: <3D3EEC5F00049E81@riosf05.globoi.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/25 X-Sequence-Number: 1370 hmm.. you could try.. for(var i=0; $dados = pg_fetch_array($limite, $i); i++) { $nome = $dados["nome"]; echo "Name: $nome
"; } I believe your error is your not passing pg_fetch_array() the row you wish to return. It *may* or may not work that way. But leaving it open like that is sure to cause an error sooner or later. Hope this helps David angelo.rigo@globo.com wrote: >Hi i am trying to build >previous and next links from a table selection, the code below stops working >at the line which says : > >while ($dados = pg_fetch_array($limite)) { > $nome = $dados["nome"]; > echo "Nome: $nome
"; > >the warning says: >Wrong parameter count for pg_fetch_array() > >i get this code from a php mysql and try to adapt to my needs, is that any >parameter wrong? wich can be? > > > >$conn = pg_connect("dbname=sondagem user=postgres"); >?> >$busca = "SELECT nome AS data FROM aprovados ORDER BY nome ASC "; >?> >$total_reg = "10"; // número de registros por página >?> >if (!$pagina) { > $pc = "1"; >} else { > $pc = $pagina; >} >?> >$inicio = $pc - 1; >$inicio = $inicio * $total_reg; >?> >$limite = pg_exec("$busca LIMIT $inicio,$total_reg"); >$todos = pg_exec("$busca"); > >$tr = pg_numrows($todos); // verifica o número total de registros >$tp = $tr / $total_reg; // verifica o número total de páginas > >// vamos criar a visualização >while ($dados = pg_fetch_array($limite)) { > $nome = $dados["nome"]; > echo "Nome: $nome
"; >} > >// agora vamos criar os botões "Anterior e próximo" >$anterior = $pc -1; >$proximo = $pc +1; >if ($pc>1) { > echo " <- Anterior "; >} >echo "|"; >if ($pc<$tp) { > echo " Próxima ->"; >} >?> > >________________________________________ >A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com.br. > > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > > From scott.marlowe@ihs.com Thu Aug 8 17:19:32 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 947B9475452 for ; Thu, 8 Aug 2002 13:19:32 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 8D50B475966 for ; Thu, 8 Aug 2002 13:19:31 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.4/8.12.4) with ESMTP id g78HIlOt024535; Thu, 8 Aug 2002 11:18:48 -0600 (MDT) Date: Thu, 8 Aug 2002 11:03:38 -0600 (MDT) From: "scott.marlowe" To: Cc: Subject: Re: pg_fetch_array problem In-Reply-To: <3D3EEC5F00049E81@riosf05.globoi.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/26 X-Sequence-Number: 1371 What version of PHP are you running? The autoincrementing nature of the row value in pg_fetch_array wasn't included until PHP 4.1.0 On Thu, 8 Aug 2002 angelo.rigo@globo.com wrote: > Hi i am trying to build > previous and next links from a table selection, the code below stops working > at the line which says : > > while ($dados = pg_fetch_array($limite)) { > $nome = $dados["nome"]; > echo "Nome: $nome
"; > > the warning says: > Wrong parameter count for pg_fetch_array() > > i get this code from a php mysql and try to adapt to my needs, is that any > parameter wrong? wich can be? > > > > $conn = pg_connect("dbname=sondagem user=postgres"); > ?> > $busca = "SELECT nome AS data FROM aprovados ORDER BY nome ASC "; > ?> > $total_reg = "10"; // número de registros por página > ?> > if (!$pagina) { > $pc = "1"; > } else { > $pc = $pagina; > } > ?> > $inicio = $pc - 1; > $inicio = $inicio * $total_reg; > ?> > $limite = pg_exec("$busca LIMIT $inicio,$total_reg"); > $todos = pg_exec("$busca"); > > $tr = pg_numrows($todos); // verifica o número total de registros > $tp = $tr / $total_reg; // verifica o número total de páginas > > // vamos criar a visualização > while ($dados = pg_fetch_array($limite)) { > $nome = $dados["nome"]; > echo "Nome: $nome
"; > } > > // agora vamos criar os botões "Anterior e próximo" > $anterior = $pc -1; > $proximo = $pc +1; > if ($pc>1) { > echo " <- Anterior "; > } > echo "|"; > if ($pc<$tp) { > echo " Próxima ->"; > } > ?> > > ________________________________________ > A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com.br. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From scott.marlowe@ihs.com Thu Aug 8 17:21:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A1F66475992 for ; Thu, 8 Aug 2002 13:21:57 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id D3D51475973 for ; Thu, 8 Aug 2002 13:21:56 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.4/8.12.4) with ESMTP id g78HK5Ot025542; Thu, 8 Aug 2002 11:20:05 -0600 (MDT) Date: Thu, 8 Aug 2002 11:04:55 -0600 (MDT) From: "scott.marlowe" To: "David C. Brown" Cc: , Subject: Re: pg_fetch_array problem In-Reply-To: <3D52A2EA.6040204@centennialwines.com> 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: 200208/27 X-Sequence-Number: 1372 On Thu, 8 Aug 2002, David C. Brown wrote: > hmm.. you could try.. > > for(var i=0; $dados = pg_fetch_array($limite, $i); i++) { > $nome = $dados["nome"]; > echo "Name: $nome
"; > } > > I believe your error is your not passing pg_fetch_array() the row you > wish to return. It *may* or may not work that way. But leaving it open > like that is sure to cause an error sooner or later. Actually, no. In the latest and greatest version of PHP, pg_fetch_array returns false when it runs out of rows, so you can just use: while ($row = pg_fetch_array){ dosomething here... }