title: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax [Php PDO]
body: <p>I have searched for an answer on numerous sites, however it seems like no one have had the same problem as I am having right now, the ones I have come across.</p>
  
  <p>The issue is that am getting this error message:</p>
  
  <blockquote>
    <p>Error: 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 '), NULL)' at line 2</p>
  </blockquote>
  
  <p>The beginning of my code looks like this. I have been staring at it but I don't seem to find the problem, any help?</p>
  
  <pre><code>&lt;?php
  $dbhost="host";   &lt;-- this is line 2.
  $dbname="db";
  $dbusername="user";
  $dbpassword="pass";
  
  ini_set("error_reporting", E_ALL);
  
  if(isset($_POST) &amp;&amp; !empty($_POST["namn"])) {
  
  try {
  $link = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbusername, $dbpassword);
  $link-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  $stmt = $link-&gt;prepare("INSERT INTO `eventcustomers` (`namn`,`enamn`,`datum`,`personnr`,`kon`,`telefon`,`epost`,`allergier`,`kategori`,`brodtext`,`reseto`,`eid`)
      VALUES(:namn, :enamn, NOW(), :personnr, :kon, :telefon, :epost, :allergier, :kategori, :brodtext, time(), :eid)");
  
  $stmt-&gt;bindParam(':namn', $_POST["namn"]);
  $stmt-&gt;bindParam(':enamn', $_POST["enamn"]);
  $stmt-&gt;bindParam(':personnr', $_POST["personnr"]);
  $stmt-&gt;bindParam(':kon', $_POST["kon"]);
  $stmt-&gt;bindParam(':telefon', $_POST["telefon"]);
  $stmt-&gt;bindParam(':epost', $_POST["epost"]);
  $stmt-&gt;bindParam(':allergier', $_POST["allergier"]);
  $stmt-&gt;bindParam(':kategori', $_POST["kategori"]);
  $stmt-&gt;bindParam(':brodtext', $_POST["brodtext"]);
  $stmt-&gt;bindParam(':eid', $_POST["eid"]);
  $stmt-&gt;execute();
      }
  catch(PDOException $e)
      {
      echo "Error: " . $e-&gt;getMessage();
      }
  }
  $link = null;
  
      ?&gt;
  </code></pre>
  
  <p>I have tried without the usage of (`), but the messsage is the same.</p>