hi all,
pls help me... im just a beginner in php...
there is a problem with my code. when i give one term for searching it works, but when its two shows an error message like this
Invalid SQL: SELECT * FROM tbl_candidate WHERE key_skills LIKE '%php%' OR key_skills LIKE '%net%' key_skills LIKE '%php%' OR key_skills LIKE '%net%' key_skills LIKE '%php%' OR key_skills LIKE '%net%'
here is my code
<?php
//Candidate Search
$sql = "SELECT * FROM tbl_candidate WHERE " ;
$sql1 = "";
if($key_skills!="")
{
$special_chars=array("+", "-", "/", ",", "'", "\"", ";", ":", "_", "*", "&", "^", "%",".", "$", "@", "!", "`", "(",")", "|", "\\", "<", ">", "?", ",", "{", "}", "[", "]", "=", "~","%27");
$key_skills1 = str_replace($special_chars," ",$key_skills);
$keywords=explode(" ",$key_skills1);
$count = count($keywords);
foreach($keywords as $keywords1){
if(strlen($keywords1)<=3 ){
for($i=0; $i<$count; $i++){
if($keywords[$i] !=""){
if($i==0){
$sql1 .=" key_skills LIKE '%$keywords[$i]%'";
}
else{
$sql1 .=" OR key_skills LIKE '%$keywords[$i]%'";
}
$i++;
}
}
//}
}
//}
else{
$sql1 .= " MATCH(key_skills) AGAINST('+$keywords1+'IN BOOLEAN MODE)";
}
}
}
$sql .=" $sql1";
echo $sql;
?>
tnx in advnc