Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Robson Andrei

[Resolvido] Warning: mysql_num_rows() expects parameter 1 to be r

Recommended Posts

Ola galera to precisando de uma ajuda, meu ta dando o seguinte erro!

 

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\seo\url\categoria.php on line 4

index.php

<?php include"config.php";
$conecta = mysql_connect($servidor, $usuario, $senha);
$selDb   = mysql_select_db($db);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Url's Amigáveis</title>
</head>

<body>
<?php include_once("menu.php");?>
<?php
$url  = $_GET['url'];
$urlE = explode('/', $url);
$arquivo = $urlE['0'];
$post    = $urlE['1'];

$paginas = array('empresa', 'contato');

if(isset($post) && $post != ''){
include "single.php";
}elseif(isset($arquivo) && in_array($arquivo, $paginas)){
include "$arquivo.php";
}elseif(isset($arquivo) && $arquivo == ''){
include "home.php";
}else{
include "categoria.php";
}
?>
</body>
</html>

categoria.php

<h1>Categoria</h1>
<?php 
$pegaCat = mysql_query("SELCET * FROM urls WHERE categoria = '$arquivo'");
$pegaCount = mysql_num_rows($pegaCat);

if($pegaCount <= '0'){
echo 'Opssssssssss Não encontramos o que procura!';	
}else{
echo '<ul>';

while($res = mysql_fetch_array($pegaCat)){
	$titulo = $res['nome'];
	$link   = $res['slug'];

	echo '<li>';
	echo '<a href="'.$urlBase.'/'.$arquivo.'/'.$link.'" title="'.$titulo.'">'.$titulo.'</a>';
	echo '</li>';
}
echo '</ul>';
}
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

troca:

$pegaCat = mysql_query("SELECT * FROM urls WHERE categoria = '$arquivo'") or die(mysql_error());
$pegaCount = mysql_num_rows($pegaCat);

por:

$pegaCat = mysql_query("SELECT * FROM urls WHERE categoria = '$arquivo'");
if( !$pegaCat ) die( mysql_error() );

$pegaCount = mysql_num_rows($pegaCat);

Compartilhar este post


Link para o post
Compartilhar em outros sites

Erro de código, repare na consulta mysql:

 

$pegaCat = mysql_query("SELCET * FROM urls WHERE categoria = '$arquivo'");

 

o correto é SELECT e não SELCET, como está no código.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Erro de código, repare na consulta mysql:

 

$pegaCat = mysql_query("SELCET * FROM urls WHERE categoria = '$arquivo'");

 

o correto é SELECT e não SELCET, como está no código.

 

Valeu brother... nem me liguei, num erro tão besta como esse!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.