title: Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in you
body: <pre><code>  $wordsAry = explode(&quot; &quot;, $search);
  $wordsCount = count($wordsAry);
  $queryCondition = &quot; WHERE &quot;;
  for($i=0;$i&lt;$wordsCount;$i++) {
      $queryCondition .= &quot;`location` LIKE '%$wordsAry[$i]%'&quot;;
      if($i!=$wordsCount-1) {
          $queryCondition .= &quot; OR &quot;;
      }
  }
  echo $queryCondition;
  
  $sql1 = &quot;SELECT * FROM `shelves_instruments` 
  :szukaj
  ORDER BY location ASC&quot;;
  $licz_ilosc = $connect_db -&gt; prepare($sql1);
  $licz_ilosc -&gt; bindValue(':szukaj', $queryCondition, PDO::PARAM_STR);
  $licz_ilosc -&gt; execute(); 
  $ilosc_stron = $licz_ilosc-&gt;rowCount();
  </code></pre>
  <blockquote>
  <p>WHERE <code>location</code> LIKE '%walida%'</p>
  </blockquote>
  <blockquote>
  <p>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
  <code>location</code> LIKE '%walida%'' ORDER BY location ASC' at line 2 in</p>
  </blockquote>
  <p>What could be wrong?</p>