pg_fetch_array problem
pg_fetch_array problem
От:
angelo.rigo@globo.com
Дата:
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?
";
}
// 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.
Re: pg_fetch_array problem
От:
"David C. Brown" <dbrown@centennialwines.com>
Дата:
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
>
>
>
Re: pg_fetch_array problem
От:
"scott.marlowe" <scott.marlowe@ihs.com>
Дата:
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
>
Re: pg_fetch_array problem
От:
"scott.marlowe" <scott.marlowe@ihs.com>
Дата:
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...
}