Gdy się wpiszę jeden wyraz to wyszukiwarka działa bardzo dobrze, ale jak się wpisze więcej wyrazów do wyszukiwarki to pokazuje się taki błąd:
Zapytanie dla wyszukiwarki było: TEST TEST i pojawił się ten komunikat:
A tu jest kod php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Search extends Controller
{
function __construct()
{
parent::__construct();
log_message('debug', 'Search Controller Initialized');
$this->load->model('init_model');
$this->load->model('category_model');
$this->load->helper('form');
}
function index()
{
$data['title'] = $this->init_model->get_setting('site_name');
$data['cat_tree'] = $this->category_model->get_cats_for_select();
$input = $this->input->post('searchtext', TRUE);
$category = (int)$this->input->post('category', TRUE);
if($input <> '' || $category <> '')
{
if ($input)
{
$insert = array('searchlog_term' => $input);
$this->db->insert('searchlog', $insert);
}
$this->db->from('articles');
$this->db->join('article2cat', 'articles.article_id = article2cat.article_id', 'left');
if($category)
{
$this->db->where('category_id', $category);
}
$this->db->where('article_display', 'Y');
{
$keywords = array();
$keywords = explode(" ", $input);
$numkeywords = count($keywords);
$wherestring = "";
for ($i = 0; $i < $numkeywords; $i++)
{
if ($i > 0)
{
$wherestring = mysql_real_escape_string($wherestring) . " AND ";
}
$wherestring = $wherestring .
" (article_title LIKE '%". mysql_real_escape_string($keywords[$i]) .
"%' OR article_short_desc LIKE '%" . mysql_real_escape_string($keywords[$i]) .
"%' OR article_description LIKE '%". mysql_real_escape_string($keywords[$i]) ."%') ";
}
$this->db->where($wherestring,NULL,FALSE);
}
$this->db->orderby('article_order', 'DESC');
$this->db->orderby('article_hits', 'DESC');
$data['articles'] = $this->db->get();
$data['searchtext'] = $input;
$data['category'] = $category;
}
$this->init_model->display_template('search', $data);
}
}
a problem leży w tym miejscu: od linii 40-57
{
$keywords = array();
$keywords = explode(" ", $input);
$numkeywords = count($keywords);
$wherestring = "";
for ($i = 0; $i < $numkeywords; $i++)
{
if ($i > 0)
{
$wherestring = mysql_real_escape_string($wherestring) . " AND ";
}
$wherestring = $wherestring .
" (article_title LIKE '%". mysql_real_escape_string($keywords[$i]) .
"%' OR article_short_desc LIKE '%" . mysql_real_escape_string($keywords[$i]) .
"%' OR article_description LIKE '%". mysql_real_escape_string($keywords[$i]) ."%') ";
}
$this->db->where($wherestring,NULL,FALSE);
}
kolega mi powiedział tak:
ale nie wiem jak to zrobić.
STRONA LIVE: http://faq.sebastian.boo.pl/