Sempre que o erro acontecer em mysql_fetch_row, mysql_num_rows e funções do tipo, pode ter certeza de que o problema é no mysql_query. Erro no SQL. Use a dica do or die das postagens anteriores.
Bom dia Leo,
Me desculpe por estar tomando tanto seu tempo, é que já procurei em varios lugares na internet e não consegui encontrar uma solução para o meu problema.
Será que você poderia dar uma olhada no código e me ajudar encontrar uma solução? Já estou ficando desesperada de novo, se puder me ajudar ficarei muito agradecida, segue o código:
<?php require_once('Connections/presentes.php'); ?>
<?php
// Require the MXI classes
require_once ('includes/mxi/MXI.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
// Verifica as preco
if(isset($_GET['preco']) && is_numeric($_GET['preco']) && $_GET['preco'] > 0) {
$busca .= "AND p_preco > ".$_GET['preco']." ";
$setpreco = 1;
}
if(isset($_GET['preco']) && $_GET['preco'] != 0 && $setpreco == NULL){
$preco1 = explode("__", $_GET['preco']);
$valorde = $preco1[0];
$valorate = $preco1[1];
$busca .= "AND p_preco > '$valorde' AND p_preco < '$valorate'";
}
// Verifica as categoria
if (isset($_GET['categoria']) && is_numeric ($_GET['categoria']) && $_GET['categoria'] > 0 ) {
$busca .= "AND p_categoria_id = ".$_GET['categoria']." ";
}
// Verifica as genero
if (isset($_GET['genero']) && is_numeric ($_GET['genero']) && $_GET['genero'] > 0 ) {
$busca .= "AND p_sexo_id = ".$_GET['genero']." ";
}
// Verifica as evento
if (isset($_GET['evento']) && is_numeric ($_GET['evento']) && $_GET['evento'] > 0 ) {
$busca .= "AND (p_evento_id LIKE '".$_GET['evento'].",%' OR p_evento_id LIKE '%,".$_GET['evento'].",%' OR p_evento_id LIKE '%,".$_GET['evento']."' OR p_evento_id LIKE '".$_GET['evento']."')";
}
// Verifica as idade
if (isset($_GET['idade']) && is_numeric ($_GET['idade']) && $_GET['idade'] > 0 ) {
$busca .= "AND (p_idade_id LIKE '".$_GET['idade'].",%' OR p_idade_id LIKE '%,".$_GET['idade'].",%' OR p_idade_id LIKE '%,".$_GET['idade']."' OR p_idade_id LIKE '".$_GET['idade']."')";
}
// Verifica as profissao
if (isset($_GET['profissao']) && is_numeric ($_GET['profissao']) && $_GET['profissao'] > 0 ) {
$busca .= "AND (p_profissao_id LIKE '".$_GET['profissao'].",%' OR p_profissao_id LIKE '%,".$_GET['profissao'].",%' OR p_profissao_id LIKE '%,".$_GET['profissao']."' OR p_profissao_id LIKE '".$_GET['profissao']."')";
}
// Verifica as hobbies
if (isset($_GET['hobbies']) && is_numeric ($_GET['hobbies']) && $_GET['hobbies'] > 0 ) {
$busca .= "AND (p_hobbies_id LIKE '".$_GET['hobbies'].",%' OR p_hobbies_id LIKE '%,".$_GET['hobbies'].",%' OR p_hobbies_id LIKE '%,".$_GET['hobbies']."' OR p_hobbies_id LIKE '".$_GET['hobbies']."')";
}
// Imprime sql na tela
//echo $busca;
mysql_select_db($database_presentes, $presentes);
$query_rsEventos = "SELECT * FROM eventos ORDER BY evento ASC";
$rsEventos = mysql_query($query_rsEventos, $presentes) or die(mysql_error());
$row_rsEventos = mysql_fetch_assoc($rsEventos);
$totalRows_rsEventos = mysql_num_rows($rsEventos);
mysql_select_db($database_presentes, $presentes);
$query_rsGenero = "SELECT * FROM genero ORDER BY genero ASC";
$rsGenero = mysql_query($query_rsGenero, $presentes) or die(mysql_error());
$row_rsGenero = mysql_fetch_assoc($rsGenero);
$totalRows_rsGenero = mysql_num_rows($rsGenero);
mysql_select_db($database_presentes, $presentes);
$query_rsIdade = "SELECT * FROM idade ORDER BY id_idade ASC";
$rsIdade = mysql_query($query_rsIdade, $presentes) or die(mysql_error());
$row_rsIdade = mysql_fetch_assoc($rsIdade);
$totalRows_rsIdade = mysql_num_rows($rsIdade);
mysql_select_db($database_presentes, $presentes);
$query_rsProfissao = "SELECT * FROM profissoes ORDER BY profissao ASC";
$rsProfissao = mysql_query($query_rsProfissao, $presentes) or die(mysql_error());
$row_rsProfissao = mysql_fetch_assoc($rsProfissao);
$totalRows_rsProfissao = mysql_num_rows($rsProfissao);
mysql_select_db($database_presentes, $presentes);
$query_rsHobbies = "SELECT * FROM hobbies ORDER BY hobbie ASC";
$rsHobbies = mysql_query($query_rsHobbies, $presentes) or die(mysql_error());
$row_rsHobbies = mysql_fetch_assoc($rsHobbies);
$totalRows_rsHobbies = mysql_num_rows($rsHobbies);
mysql_select_db($database_presentes, $presentes);
$query_rsCategoria = "SELECT * FROM categorias ORDER BY categoria ASC";
$rsCategoria = mysql_query($query_rsCategoria, $presentes) or die(mysql_error());
$row_rsCategoria = mysql_fetch_assoc($rsCategoria);
$totalRows_rsCategoria = mysql_num_rows($rsCategoria);
$maxRows_rsProdutos = 9;
$pageNum_rsProdutos = 0;
if (isset($_GET['pageNum_rsProdutos'])) {
$pageNum_rsProdutos = $_GET['pageNum_rsProdutos'];
}
$startRow_rsProdutos = $pageNum_rsProdutos * $maxRows_rsProdutos;
mysql_select_db($database_presentes, $presentes);
$query_rsProdutos = "SELECT * FROM produtos WHERE p_status = 1 $busca";
$query_limit_rsProdutos = sprintf("%s LIMIT %d, %d", $query_rsProdutos, $startRow_rsProdutos, $maxRows_rsProdutos);
$rsProdutos = mysql_query($query_limit_rsProdutos, $presentes) or die(mysql_error());
$row_rsProdutos = mysql_fetch_assoc($rsProdutos);
if (isset($_GET['totalRows_rsProdutos'])) {
$totalRows_rsProdutos = $_GET['totalRows_rsProdutos'];
} else {
$all_rsProdutos = mysql_query($query_rsProdutos);
$totalRows_rsProdutos = mysql_num_rows($all_rsProdutos);
}
$totalPages_rsProdutos = ceil($totalRows_rsProdutos/$maxRows_rsProdutos)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR...nsitional.dtd"><html xmlns="
http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Presentes Criativos, Presentes Originais, Presentes Diferentes | Perfeito Presente</title>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
<meta name="copyright" content="LeandroFranco.COM"/>
<meta name="author" content="
http://www.leandrofr...rofranco.com"/><meta name="robots" content="index,follow" />
<meta name="googlebot" content="index,follow" />
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="box">
<?php
mxi_includes_start("header.php");
require(basename("header.php"));
mxi_includes_end();
?>
<?php
mxi_includes_start("left-sidebar.php");
require(basename("left-sidebar.php"));
mxi_includes_end();
?>
<div id="conteudo">
<?php
mxi_includes_start("busca.php");
require(basename("busca.php"));
mxi_includes_end();
?>
<div id="conteudo_anuncios">
<h1 class="titulo_anuncio">Resultado da busca para presentes <?php echo $busca ?></h1>
<table border="1">
<tr>
<?php
do { // horizontal looper version 3
?>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div id="conteudo_anuncios_presente">
<h1 class="conteudo_anuncios_presente_titulo" title="<?php echo $row_rsProdutos['p_titulo']; ?>"><?php echo $row_rsProdutos['p_titulo']; ?></h1>
<a href="<?php echo $row_rsProdutos['p_url']; ?>" title="<?php echo $row_rsProdutos['p_titulo']; ?>" target="_blank"><img src="produtos/<?php echo $row_rsProdutos['p_foto']; ?>" alt="Presente <?php echo $row_rsProdutos['p_titulo']; ?>" width="172" height="167" border="0" /></a><br />
<h2 class="conteudo_anuncios_presente_descricao"><?php echo $row_rsProdutos['p_descricao']; ?> + </h2>
<span class="conteudo_anuncios_presente_preco">R$ <?php echo $row_rsProdutos['p_preco']; ?></span>
<div align="center" class="conteudo_anuncios_presente_detalhes"><a href="<?php echo $row_rsProdutos['p_url']; ?>" title="<?php echo $row_rsProdutos['p_titulo']; ?>" target="_blank">+ Detalhes</a></div>
</div></td>
</tr>
</table></td>
<?php
$row_rsProdutos = mysql_fetch_assoc($rsProdutos);
if (!isset($nested_rsProdutos)) {
$nested_rsProdutos= 1;
}
if (isset($row_rsProdutos) && is_array($row_rsProdutos) && $nested_rsProdutos++ % 3==0) {
echo "</tr><tr>";
}
} while ($row_rsProdutos); //end horizontal looper version 3
?>
</tr>
</table>
<!-- FECHA PRESENTE-->
</div><!-- FECHA CONTEUDO ANUNCIOS-->
</div><!-- FECHA CONTEUDO-->
<?php
mxi_includes_start("right-sidebar.php");
require(basename("right-sidebar.php"));
mxi_includes_end();
?>
<?php
mxi_includes_start("footer.php");
require(basename("footer.php"));
mxi_includes_end();
?>
</div><!-- FECHA BOX-->
</body>
</html>
<?php
//coloquei @ para não aparecer mensagens
@mysql_free_result($rsEventos);
@mysql_free_result($rsGenero);
@mysql_free_result($rsIdade);
@mysql_free_result($rsProfissao);
@mysql_free_result($rsHobbies);
@mysql_free_result($rsCategoria);
@mysql_free_result($rsProdutos);
?>
Agradeço muito pela sua atenção e ajuda.
Beijos
Edição feita por: Perdida no Código, 16/01/2011, 00:45.