Ir para conteúdo
Fórum Script Brasil
  • 0

Que Erro É Esse?


carol

Pergunta

OLá gente você sabem que seria esse erro?

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/amorajat/public_html/site/classes/db.php on line 29

Essa é a linha 29

return ( mysql_num_rows ($res) );

o arquivo inteiro é esse embaixo,abraços

<?php 
class DB { 
var $res_per_page; 
var $pageNum; 
var $res; 
var $db; 
var $page; 
var $row; 

function DB () { 
if (file_exists("admin/config/db.inc.php")) 
{ 
include "admin/config/db.inc.php"; 
} 
else 
{ 
include "../admin/config/db.inc.php"; 
} 

} 

function Q ( $SQL ) { 
return ( mysql_query ( $SQL ) ); 
} 
function R ( $res ) { 
return ( mysql_fetch_array ( $res ) ); 
} 
function NumRows ( $res ) { 
return ( mysql_num_rows ($res) ); 
} 

function affected ($res) { 
return ( mysql_affected_rows () ); 
} 

function pages($query,$res_per_page,$resultpage,$db) 
{ 
$this->db = $db; 
$this->res = $this->Q($query); 
$this->res_per_page = $res_per_page; 
//echo $res_per_page; 
//echo $resultpage; 
if ((int)$resultpage <= 0) $resultpage = 1; 
$res = $this->res; 
if ($resultpage > $this->NumRows($this->res)) 
$resultpage = $this->NumRows($this->res); 
$this->setPageNum($resultpage); 
} 

function setPageNum($pageNum) 
{ 
if ($pageNum > $this->getNumPages($this->res) or 
$pageNum <= 0) return FALSE; 

$this->page = $pageNum; 
$this->row = 0; 
echo $this->pageNum; 

mysql_data_seek($this->res,($pageNum-1) * $this->res_per_page); 
} 

function getPageNum() 
{ 

return $this->page; 
} 

function isLastPage() 
{ 
return ($this->page >= $this->getNumPages($this->res)); 
} 

function isFirstPage() 
{ 
return ($this->page <= 1); 
} 

function fetchArray() 
{ 
if (!$this->res) return FALSE; 
if ($this->row >= $this->res_per_page) return FALSE; 
$this->row++; 
return mysql_fetch_array($this->res); 
} 

function getNumPages() 
{ 

if (!$this->res) return FALSE; 

return ceil(mysql_num_rows($this->res) / 
(float)$this->res_per_page); 
} 



function getPagePrev($queryvars = '') 
{ 

$nav = ""; 
if (!$this->isFirstPage()) 
{ 
$nav .= "<img src=\"layout_img/arrow-listing-back.gif\" width=\"10\" height=\"10\" hspace=\"4\" vspace=\"6\" align=\"top\">&nbsp;<span class=\"link-main\"><a class=\"link-main\" href=\"?resultpage=". 
($this->getPageNum()-1).'&'.$queryvars.'">' . BACK_RES . '</a> '; 
} 
return $nav; 
} 

function getPageNext($queryvars = '') 
{ 

$nav = ""; 
if (!$this->isLastPage()) 
{ 
$nav .= "<span class=\"link-main\"><a class=\"link-main\" href=\"?resultpage=". 
($this->getPageNum()+1).'&'.$queryvars.'">'. FORW_RES . '</a> <img src="layout_img/arrow-listing-fwd.gif" width="10" height="10" hspace="4" vspace="6" align="absmiddle">'; 
} 
return $nav; 
} 

function getPageNav($queryvars = '') 
{ 

$nav = ""; 

if (!$this->isFirstPage()) 
{ 
$nav .= "<a href=\"?resultpage=". 
($this->getPageNum()-1).'&'.$queryvars.'">' . PREV_RES . '</a> '; 
} 
if ($this->getNumPages($this->res) > 1) 
for ($i=1; $i<=$this->getNumPages($this->res); $i++) 
{ 
if ($i==$this->page) 
$nav .= "$i "; 
else 
$nav .= "<a href=\"?resultpage={$i}&". 
$queryvars."\">{$i}</a> "; 
} 
if (!$this->isLastPage()) 
{ 
$nav .= "<a href=\"?resultpage=". 
($this->getPageNum()+1).'&'.$queryvars.'">'. NEXT_RES . '</a> '; 
} 

return $nav; 
} 



} 
?>

obrigada a todos!

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Como diria Arnaldo César Coelho, a regra é clara:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/amorajat/public_html/site/classes/db.php on line 29

Ou seja:

Você está passando como parâmetro da função mysql_num_rows() um resultset inválido.

Verifique o código que gera o resultset $res, o erro possivelmente está lá.

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...