Tengo un sitio desarrollado en PHP, y este tiene un buscador. Cuando se hace una busqueda y los resultados son desplegados en mas de 1 pagina, el link a la segunda pagina me avienta un error asi:
Cita:
--------------------------------------------------------------------SQL/DB Error -- [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%%' AND mnl_items.active='yes' GROUP BY]
Aqui esta el codigo completo del php, por favor alguien sabra el error? Por favor.. alguien que me ayude.
Código PHP:
<?php
// ANIMERATE
// | search.php version history:
// | version 1.0 04/04/2003
// +----------------------------------------------------------------------+
//
require ( "config.php" );
require ( "common.php" );
require ( "includes/mysql.php" );
require ( "includes/interface.php" );
require ( "includes/inc_reviews.php" );
require ( "global_config.php" );
global $db;
$search = $_POST['search'];
$search_type = $_POST['search_type'];
$limit = $CONFIG_VAR['num_records_display'];
$page = "search";
include_template ( $CONFIG_VAR['page_header_template'] );
$Prev = "Anterior";
$Next = "Siguiente";
// This creates the start of the main body table
echo "<!-- Start of main body table -->\n\n";
echo "<table width=\"" . $CONFIG_VAR['body_width_value'] . "\" align=\"center\" cellspacing=\"0\" border=\"0\" cellpadding=\"0\">\n";
echo "<tr>\n";
// This creates the lefthand menu column
include_template ( $CONFIG_VAR['left_column_template'] );
// This creates the middle table
echo "<!-- Start of middle column -->\n\n";
echo "<td valign=\"top\">\n";
// This creates the breadcrumb trail
breadcrumbs( $page );
echo "<table class=\"txtwhite\" bgcolor=\"061376\" width=\"96%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"tbodysmall\"><tr><td width=\"25%\">*<b>Titulo</b></td><td align=\"center\" width=\"18%\"><b>Calificación y Recomendación</b></td><td align=\"center\" width=\"8%\"><b>No. de Criticas</b></td><td width=\"45%\" align=\"center\"><b>Sinopsis</b></td></tR></table>\n";
if ( empty ( $offset ) )
{
$offset = 0;
}
$query = "SELECT mnl_items.item_id,
mnl_items.item,
mnl_items.cat_id,
mnl_items.sub_cat_id,
mnl_items.description,
mnl_items.item_url,
mnl_items.url_click_through,
mnl_items.cost,
mnl_items.config_field_1,
mnl_items.config_field_2,
mnl_items.config_field_3,
mnl_items.config_field_4,
mnl_items.config_field_5,
mnl_items.config_field_6,
mnl_items.config_field_7,
mnl_items.config_field_8,
Count( mnl_reviews.review_id ) AS number_reviews,
IF(Avg( mnl_reviews.review_score ),Avg( mnl_reviews.review_score ),0) AS average_score,
SUM( mnl_reviews.review_score ) AS total_scores
FROM mnl_items
LEFT JOIN mnl_reviews ON mnl_items.item_id = mnl_reviews.item_id AND mnl_reviews.active='yes'
WHERE mnl_items." . $search_type . " LIKE '%$search%' AND mnl_items.active='yes'
GROUP BY mnl_items.item, mnl_items.item_id";
$result = $db->get_results ( $query );
$num_rows = $db->num_rows;
if ( $num_rows > 0 )
{
// run the query again with the limiter
$query .= " LIMIT " . $offset . "," . $limit;
$result = $db->get_results ( $query );
foreach ( $result as $val )
{
$cat_id = $val->cat_id;
$sub_cat_id = $val->sub_cat_id;
item_summary ( "summary", $val->item_id, $val->item, $val->description, $val->item_url, $val->url_click_through, $val->cost, $val->number_reviews, $val->average_score, $val->total_scores, $val->config_field_1, $val->config_field_2, $val->config_field_3, $val->config_field_4, $val->config_field_5, $val->config_field_6, $val->config_field_7, $val->config_field_8 );
}
}
else
{
print_message ( "No se encontro ninguna " . $CONFIG_VAR['item_type'] . " en nuestra base de datos", "Por favor regrese con su navegador." );
die;
}
$pages = intval ( $num_rows/$limit );
$url = "<a href=\"search.php?search=" . $search . "&sort=" . $sort;
if ( $num_rows % $limit)
{
$pages++;
}
echo "<table width=\"80%\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td class=\"mnlpagination\" align=\"center\">Página \n";
for ( $i = 1;$i <= $pages;$i++ )
{
$newoffset=$limit*($i-1);
echo $url . "&offset=" . $newoffset . "\">$i</a>\n";
}
if ( $offset > 1 )
{
$prevoffset = $offset - $limit;
echo $url . "&offset=" . $prevoffset . "\">$Prev</a>\n";
}
if ( $num_rows > ( $offset + $limit ) )
{
$nextoffset = $offset + $limit;
echo $url . "&offset=" . $nextoffset . "\">$Next</a>\n";
}
echo "</tr>\n";
echo "</table>\n";
//This creates the main menu along the bottom of the main column
bottom_menu( "yes" );
echo "</td>\n";
echo "<!-- End of middle column -->\n\n";
// This creates the right hand menu column
include_template ( $CONFIG_VAR['right_column_template'] );
// This ends the main body table
echo "</tr>\n";
echo "</table>\n";
//This creates the page footer
include_template ( $CONFIG_VAR['page_footer_template'] );
?>