Bom galera to com um pequeno problema, toda vez que eu vou efetuar uma certa busca no site o resultado dessa busca não é exibido, no final da página aparece a seguinte mensagem:
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/saulolag/public_html/auto/resultado.php on line 1101
não sei bem o que é, sera que alguém poderia me ajudar?
abaixo segue os códigos do arquivo resultado.php
Pergunta
saulus
Bom galera to com um pequeno problema, toda vez que eu vou efetuar uma certa busca no site o resultado dessa busca não é exibido, no final da página aparece a seguinte mensagem:
não sei bem o que é, sera que alguém poderia me ajudar? abaixo segue os códigos do arquivo resultado.php<?php require_once('Connections/portalveic.php'); ?> <?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; } } ?> <?php require_once('Connections/portalveic.php'); ?> <?php require_once('Connections/portalveic.php'); ?> <?php require_once('Connections/portalveic.php'); ?> <?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; } } $currentPage = $_SERVER["PHP_SELF"]; mysql_select_db($database_portalveic, $portalveic); $query_mascas_lista = "SELECT * FROM marcas ORDER BY marca ASC"; $mascas_lista = mysql_query($query_mascas_lista, $portalveic) or die(mysql_error()); $row_mascas_lista = mysql_fetch_assoc($mascas_lista); $totalRows_mascas_lista = mysql_num_rows($mascas_lista); 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; } } 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; } } 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; } } $maxRows_empresa = 12; $pageNum_empresa = 0; if (isset($_GET['pageNum_empresa'])) { $pageNum_empresa = $_GET['pageNum_empresa']; } $startRow_empresa = $pageNum_empresa * $maxRows_empresa; mysql_select_db($database_portalveic, $portalveic); $query_empresa = "SELECT * FROM empresa"; $query_limit_empresa = sprintf("%s LIMIT %d, %d", $query_empresa, $startRow_empresa, $maxRows_empresa); $empresa = mysql_query($query_limit_empresa, $portalveic) or die(mysql_error()); $row_empresa = mysql_fetch_assoc($empresa); if (isset($_GET['totalRows_empresa'])) { $totalRows_empresa = $_GET['totalRows_empresa']; } else { $all_empresa = mysql_query($query_empresa); $totalRows_empresa = mysql_num_rows($all_empresa); } $totalPages_empresa = ceil($totalRows_empresa/$maxRows_empresa)-1; $maxRows_ultimos_cadastrados = 6; $pageNum_ultimos_cadastrados = 0; if (isset($_GET['pageNum_ultimos_cadastrados'])) { $pageNum_ultimos_cadastrados = $_GET['pageNum_ultimos_cadastrados']; } $startRow_ultimos_cadastrados = $pageNum_ultimos_cadastrados * $maxRows_ultimos_cadastrados; mysql_select_db($database_portalveic, $portalveic); $query_ultimos_cadastrados = "SELECT * FROM auto ORDER BY id DESC"; $query_limit_ultimos_cadastrados = sprintf("%s LIMIT %d, %d", $query_ultimos_cadastrados, $startRow_ultimos_cadastrados, $maxRows_ultimos_cadastrados); $ultimos_cadastrados = mysql_query($query_limit_ultimos_cadastrados, $portalveic) or die(mysql_error()); $row_ultimos_cadastrados = mysql_fetch_assoc($ultimos_cadastrados); if (isset($_GET['totalRows_ultimos_cadastrados'])) { $totalRows_ultimos_cadastrados = $_GET['totalRows_ultimos_cadastrados']; } else { $all_ultimos_cadastrados = mysql_query($query_ultimos_cadastrados); $totalRows_ultimos_cadastrados = mysql_num_rows($all_ultimos_cadastrados); } $totalPages_ultimos_cadastrados = ceil($totalRows_ultimos_cadastrados/$maxRows_ultimos_cadastrados)-1; $maxRows_destaques = 12; $pageNum_destaques = 0; if (isset($_GET['pageNum_destaques'])) { $pageNum_destaques = $_GET['pageNum_destaques']; } $startRow_destaques = $pageNum_destaques * $maxRows_destaques; mysql_select_db($database_portalveic, $portalveic); $query_destaques = "SELECT * FROM auto WHERE veiculo = 'Motos Usadas'"; $query_limit_destaques = sprintf("%s LIMIT %d, %d", $query_destaques, $startRow_destaques, $maxRows_destaques); $destaques = mysql_query($query_limit_destaques, $portalveic) or die(mysql_error()); $row_destaques = mysql_fetch_assoc($destaques); if (isset($_GET['totalRows_destaques'])) { $totalRows_destaques = $_GET['totalRows_destaques']; } else { $all_destaques = mysql_query($query_destaques); $totalRows_destaques = mysql_num_rows($all_destaques); } $totalPages_destaques = ceil($totalRows_destaques/$maxRows_destaques)-1; $maxRows_resultado_busca = 1; $pageNum_resultado_busca = 0; if (isset($_GET['pageNum_resultado_busca'])) { $pageNum_resultado_busca = $_GET['pageNum_resultado_busca']; } $startRow_resultado_busca = $pageNum_resultado_busca * $maxRows_resultado_busca; $colname_resultado_busca = "-1"; if (isset($_POST['marca'])) { $colname_resultado_busca = $_POST['marca']; } mysql_select_db($database_portalveic, $portalveic); $query_resultado_busca = sprintf("SELECT * FROM auto WHERE marca = %s", GetSQLValueString($colname_resultado_busca, "text")); $query_limit_resultado_busca = sprintf("%s LIMIT %d, %d", $query_resultado_busca, $startRow_resultado_busca, $maxRows_resultado_busca); $resultado_busca = mysql_query($query_limit_resultado_busca, $portalveic) or die(mysql_error()); $row_resultado_busca = mysql_fetch_assoc($resultado_busca); if (isset($_GET['totalRows_resultado_busca'])) { $totalRows_resultado_busca = $_GET['totalRows_resultado_busca']; } else { $all_resultado_busca = mysql_query($query_resultado_busca); $totalRows_resultado_busca = mysql_num_rows($all_resultado_busca); } $totalPages_resultado_busca = ceil($totalRows_resultado_busca/$maxRows_resultado_busca)-1; $queryString_resultado_busca = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_resultado_busca") == false && stristr($param, "totalRows_resultado_busca") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_resultado_busca = "&" . htmlentities(implode("&", $newParams)); } } $queryString_resultado_busca = sprintf("&totalRows_resultado_busca=%d%s", $totalRows_resultado_busca, $queryString_resultado_busca); ?> <!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=ISO-8859-1" /> <title>.::<?php echo $row_empresa['empresa']; ?>::.</title> <link rel="stylesheet" type="text/css" href="../style-projects-jquery.css" /> <script type="text/javascript" src="js/jquery.js"></script> </style> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } .style3 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #999999; } #nome{ width:200px; height:25px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } #email{ width:200px; height:25px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } #telefone{ width:200px; height:25px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } #estado{ width:200px; height:25px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } #cidade{ width:200px; height:25px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } #assunto{ width:200px; height:25px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } #mensagem{ width:200px; height:200px; border: 1px solid #CCC; background:#FFF; color:#CCC; padding-top:4px; font-family:Verdana, Geneva, sans-serif; } </style> <!-- Arquivos utilizados pelo jQuery lightBox plugin --> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" /> <!-- / fim dos arquivos utilizados pelo jQuery lightBox plugin --> <!-- Ativando o jQuery lightBox plugin --> <script type="text/javascript"> $(function() { $('#gallery a').lightBox(); }); </script> <style type="text/css"> /* jQuery lightBox plugin - Gallery style */ #gallery { width: 100%; } #gallery ul { list-style: none; } #gallery ul li { display: inline; } #gallery ul img { border: 5px solid #3e3e3e; border-width: 5px 5px 20px; } #gallery ul a:hover img { border: 5px solid #fff; border-width: 5px 5px 20px; color: #fff; } #gallery ul a:hover { color: #fff; } </style> </head> <body> <table width="820" height="1092" border="0" align="center" cellspacing="0"> <tr bgcolor="#CCCCCC"> <td colspan="3"><script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','850','height','240','src','flash/topo','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','flash/topo' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="850" height="240"> <param name="movie" value="flash/topo.swf" /> <param name="quality" value="high" /> <embed src="flash/topo.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="850" height="240"></embed> </object></noscript></td> </tr> <tr bgcolor="#CCCCCC"> <td width="212" valign="top" bgcolor="#FFFFFF"><table width="200" border="0" cellpadding="0" cellspacing="0" id="fundopesquisa"> <tr> <th width="213" scope="col"><form id="busca_veiculos" name="busca_veiculos" method="post" action="resultado.php"> <table width="90%" border="0" cellspacing="2" cellpadding="0"> <tr> <td height="41" align="center"> </td> <td align="center"> </td> </tr> <tr> <th width="20%" align="center" scope="col"> </th> <th width="80%" align="center" scope="col"><span class="dados_detalhes">Marca</span></th> </tr> <tr> <td align="center"> </td> <td align="center"><select name="marca" id="marca"> <?php do { ?> <option value="<?php echo $row_mascas_lista['marca']?>"><?php echo $row_mascas_lista['marca']?></option> <?php } while ($row_mascas_lista = mysql_fetch_assoc($mascas_lista)); $rows = mysql_num_rows($mascas_lista); if($rows > 0) { mysql_data_seek($mascas_lista, 0); $row_mascas_lista = mysql_fetch_assoc($mascas_lista); } ?> </select></td> </tr> <tr> <td align="center"> </td> <td align="center"><span class="dados_detalhes">Modelo <input type="text" name="modelo" id="modelo" /> </span></td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="right"><input type="submit" name="enviar" id="enviar" value="Buscar" /></td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> </tr> </table> </form></th> </tr> </table> <br /> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <th scope="col"><a href="listar_carros.php"><img src="imagens/btnComprar.png" width="176" height="51" border="0" /><br /> </a></th> </tr> </table> <br /> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <th scope="col"><a href="fale_conosco.php"><img src="imagens/btnVender.png" width="176" height="51" border="0" /></a></th> </tr> </table> <br /> <table width="200" border="0" cellpadding="0" cellspacing="0" id="espaco_ultimos_inseridos"> <tr> <th valign="top" scope="col"><table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr valign="top"> <th scope="col"><span class="style1">ÚLTIMOS INSERIDOS</span></th> </tr> </table> <?php do { ?> <table width="95%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <th scope="col"><hr /></th> </tr> <tr> <td align="left"><span class="ultimos_cadastros"><a href="detalhes_anuncio.php?id=<?php echo $row_ultimos_cadastrados['id']; ?>"><?php echo $row_ultimos_cadastrados['modelo']; ?></a></span></td> </tr> <tr> <td align="left" nowrap="nowrap"><span class="ultimos_cadastros">Ano: <?php echo $row_ultimos_cadastrados['ano']; ?></span></td> </tr> </table> <?php } while ($row_ultimos_cadastrados = mysql_fetch_assoc($ultimos_cadastrados)); ?> </th> </tr> </table> </td> <td width="616" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <th scope="col"><h2 class="ultimos_cadastros"><span class="titulos">RESULTADO</span></h2></th> </tr> <tr> <th scope="col"> </th> </tr> <tr> <th align="center" scope="col"> <table border="0"> <tr> <?php do { // horizontal looper version 3 ?> <td width="177"><table width="100" border="0" align="left" cellpadding="0" cellspacing="2"> <tr> <th scope="col"><a href="detalhes_anuncio.php?id=<?php echo $row_resultado_busca['id']; ?>"><img src="anuncios/<?php echo $row_resultado_busca['foto1']; ?>" width="155" height="109" border="0" /></a></th> </tr> <tr> <td align="center"><span class="ultimos_cadastros"><strong><a href="detalhes_anuncio.php?id=<?php echo $row_resultado_busca['id']; ?>"><?php echo $row_resultado_busca['modelo']; ?></a></strong></span></td> </tr> <tr> <td align="center"><span class="ultimos_cadastros"><?php echo $row_resultado_busca['marca']; ?> - <?php echo $row_resultado_busca['modelo']; ?></span></td> </tr> <tr> <td align="center"><span class="ultimos_cadastros"><?php echo $row_resultado_busca['valor']; ?></span></td> </tr> </table></td> <?php $row_empresa = mysql_fetch_assoc($empresa); if (!isset($nested_empresa)) { $nested_empresa= 1; } if (isset($row_empresa) && is_array($row_empresa) && $nested_empresa++ % 3==0) { echo "</tr><tr>"; } } while ($row_empresa); //end horizontal looper version 3 ?> </tr> </table> <table border="0"> <tr> <td><?php if ($pageNum_resultado_busca > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_resultado_busca=%d%s", $currentPage, 0, $queryString_resultado_busca); ?>"><img src="imagens/First.gif" /></a> <?php } // Show if not first page ?></td> <td><?php if ($pageNum_resultado_busca > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_resultado_busca=%d%s", $currentPage, max(0, $pageNum_resultado_busca - 1), $queryString_resultado_busca); ?>"><img src="imagens/Previous.gif" /></a> <?php } // Show if not first page ?></td> <td><?php if ($pageNum_resultado_busca < $totalPages_resultado_busca) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_resultado_busca=%d%s", $currentPage, min($totalPages_resultado_busca, $pageNum_resultado_busca + 1), $queryString_resultado_busca); ?>"><img src="imagens/Next.gif" /></a> <?php } // Show if not last page ?></td> <td><?php if ($pageNum_resultado_busca < $totalPages_resultado_busca) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_resultado_busca=%d%s", $currentPage, $totalPages_resultado_busca, $queryString_resultado_busca); ?>"><img src="imagens/Last.gif" /></a> <?php } // Show if not last page ?></td> </tr> </table> </p></th> </tr> </table> <p align="left" class="style1"><br /> </p></td> <td width="18" valign="top" bgcolor="#FFFFFF"> </td> </tr> </table> <table width="852" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr> <th bgcolor="#EBEBEB" class="style3" scope="col"><br /> <?php echo $row_empresa['empresa']; ?> - Todos os Direitos Reservados - <a href="index.php">Início</a> | <a href="empresa.php">Empresa</a> | <a href="listar_carros.php">Carros</a> | <a href="listar_motos.php">Motos</a> | <a href="financiamento.php">Financiamento</a> | <a href="fale_conosco.php">Fale Conosco</a><br /> <br /></th> </tr> </table> <p> </p> </body> </html> <?php mysql_free_result($mascas_lista); mysql_free_result($resultado_busca); mysql_free_result($ultimos_cadastrados); mysql_free_result($destaques); mysql_free_result($resultado_busca); mysql_free_result($empresa); ?>Obrigado e espero que vocês possam me ajudar.
Link para o comentário
Compartilhar em outros sites
5 respostass a esta questão
Posts Recomendados
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.