title: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064
body: <p>I am making a shop and using an input to get results, now I have the AJAX that calls the PHP script and it calls it fine, but I get an error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064</p>
  </blockquote>
  
  <p><strong>NOTE</strong>: The error line is the <code>$query-&gt;execute(array(':input'=&gt;$input))</code> line</p>
  
  <p>here's the AJAX script ( + HTML calling the function ) </p>
  
  <pre><code>                     &lt;input type="text" name="search_item" onkeyup="showItems(this.value)" id="search_item"&gt;
                       &lt;script&gt;
                          function showItems(str) {
                              if (str.length == 0) { 
  
                              } else {
                                  var xmlhttp = new XMLHttpRequest();
                                  xmlhttp.onreadystatechange = function() {
                                      if (this.readyState == 4 &amp;&amp; this.status == 200) {
                                          document.getElementById("items").innerHTML = this.responseText;
                                      }
                                  };
                                  xmlhttp.open("GET", "searchScript.php?iName=" + str, true);
                                  xmlhttp.send();
                              }
                          }
                      &lt;/script&gt;
  </code></pre>
  
  <p>and here's the called PHP:</p>
  
  <pre><code>    $input = $_REQUEST["iName"];
      $input = "%".$input."%"; 
  $dsn = 'mysql:host=xxx.com;dbname=dbNameHidden;charset=utf8mb4';
  $username = 'hidden';
  $password = 'hidden';
  
  try{
      // connect to mysql
      $con = new PDO($dsn,$username,$password);
      $con-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch (Exception $ex) {
      echo 'Not Connected '.$ex-&gt;getMessage();
  }
  $query = $con-&gt;prepare("SELECT * FROM store AS s INNER JOIN product_pictures AS pp ON s.product_id = pp.id INNER JOIN product_name AS pn ON s.product_id = pn.id WHERE product_name LIKE %:input% LIMIT 9 ");
  $query-&gt;execute(array(':input' =&gt; $input));
  $items = $query-&gt;fetchAll();
  </code></pre>