$wordsAry = explode(" ", $search);
$wordsCount = count($wordsAry);
$queryCondition = " WHERE ";
for($i=0;$i<$wordsCount;$i++) {
$queryCondition .= "`location` LIKE '%$wordsAry[$i]%'";
if($i!=$wordsCount-1) {
$queryCondition .= " OR ";
}
}
echo $queryCondition;
$sql1 = "SELECT * FROM `shelves_instruments`
:szukaj
ORDER BY location ASC";
$licz_ilosc = $connect_db -> prepare($sql1);
$licz_ilosc -> bindValue(':szukaj', $queryCondition, PDO::PARAM_STR);
$licz_ilosc -> execute();
$ilosc_stron = $licz_ilosc->rowCount();
WHERE
locationLIKE '%walida%'
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' WHERE
locationLIKE '%walida%'' ORDER BY location ASC' at line 2 in
What could be wrong?