title: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
body: <p>I get this error </p>
  
  <blockquote>
    <p>(Uncaught PDOException: SQLSTATE[42000]: Syntax error or access
    violation: 1064 You have an error in your SQL syntax;)</p>
  </blockquote>
  
  <p>I know it's regarding the code below as I get this error code in my console </p>
  
  <blockquote>
    <p>([Tue Jan 21 21:32:11.564497 2020] [proxy_fcgi:error] [pid 14681:tid
    140542562248448] [client 81.226.126.93:39132] AH01071: Got error 'PHP
    message: PHP 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 rakel IN ('3
    31-1710')' at line 1 in
    /var/www/vhosts/stockholmblaljusklan.se/httpdocs/cad/assets/includes/utl/larm.php:144\nStack
    trace:\n#0
    /var/www/vhosts/stockholmblaljusklan.se/httpdocs/cad/assets/includes/utl/larm.php(144):
    PDOStatement->execute(Array)\n#1
    /var/www/vhosts/stockholmblaljusklan.se/httpdocs/cad/sos/index.php(37):
    include('/var/www/vhosts...')\n#2 {main}\n  thrown in
    /var/www/vhosts/stockholmblaljusklan.se/httpdocs/cad/assets/includes/utl/larm.php
    on line 144', referer:
    <a href="https://stockholmblaljusklan.se/cad/sos/index.php" rel="nofollow noreferrer">https://stockholmblaljusklan.se/cad/sos/index.php</a>)</p>
  </blockquote>
  
  <p>Someone that knows how to solve this problem? Much appreciated!</p>
  
  <pre><code>if(isset($_POST['submit_units'])){
  $units = $_POST['enheter'];
  $units_2 = implode(", ", $units);
  
  $query_3 = "UPDATE larm SET enheter=:enheter WHERE id=:id";
  $stmt = $db-&gt;prepare($query_3);
  $stmt-&gt;bindparam(":enheter",$units_2);
  $stmt-&gt;bindparam(":id",$id);
  $stmt-&gt;execute();
  
  $enheter_3 = explode(", ", $units_2);
  $count_2 = str_repeat('?,', count($enheter_3) - 1) . '?';
  
  $query_4 = "UPDATE fordon SET on_call=$id WHERE rakel IN ($count_2)";
  $stmt = $db-&gt;prepare($query_4);
  $stmt-&gt;execute($enheter_3);
  }
  </code></pre>