Here is the solution...
I didn't get an error message using that SQL, but I was wondering the search always gave me result: Query returned 0 results, even if I entered the keyword that exists in the premade table (title or answer field).
I am also not sure whether that SQL is right or wrong, cause I have tried by using MySQL tools, the query always returned 0 record. Just FYI, I am using MySQL version 5.0.51b.
So I decided to make my own modification, and I'm sure this will also fix your problem, because I have tried it before release this solution here... and it works good now! :)
Let's getting started now.
Find:
//List premade answers.
Select or highlight all code from that comment until the comment below
//I admit this crap sucks...but who cares??
then replace with all code below... or... Finally, you should have the complete code just like this (see all the complete code below):
//List premade answers.
$select='SELECT DISTINCT(d.dept_name), premade.* ';
$from='FROM '.KB_PREMADE_TABLE.' premade, '.DEPT_TABLE.' d ';
//make sure the search query is 3 chars min...defaults to no query with warning message
if($_REQUEST=='search') {
if(!$_REQUEST || strlen($_REQUEST)<3) {
$errors=I_S_PREM_SEARCH_TERM;
}else{
//fulltext search.
$search=true;
$qstr.='&a='.urlencode($_REQUEST);
$qstr.='&query='.urlencode($_REQUEST);
$searchfor = $_REQUEST;
$where=" WHERE (premade.title LIKE '%$searchfor%'
OR premade.answer LIKE '%$searchfor%')
AND d.dept_id = premade.dept_id ";
if($_REQUEST)
$where.=' AND d.dept_id='.db_input($_REQUEST);
}
}
if (!isset($where)) $where = 'WHERE d.dept_id = premade.dept_id';
//I admit this crap sucks...but who cares??
Hope this helpful also to everyone.
Thanks for remind me about this, so I focused to check that SQL and make sure this search feature works. ;)
Best regards,
Masino Sinaga