title: PDO query: SQLSTATE[42000]
body: <p>When trying to insert data into a mysql table using PDO I get the following error.</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' in /home/gaz492/public_html/dayz/user/pages/admin/vip.php:26 Stack trace: #0 /home/gaz492/public_html/dayz/user/pages/admin/vip.php(26): PDO->query('INSERT INTO `cu...') #1 /home/gaz492/public_html/dayz/user/index.php(89): include_once('/home/gaz492/pu...') #2 {main} thrown in /home/gaz492/public_html/dayz/user/pages/admin/vip.php on line 26</p>
  </blockquote>
  
  <p>Here is the code on that page.</p>
  
  <p>If anyone would be able to help it would mean a lot as I have been searching everywhere for a fix, but cannot find anything that works. Ask if you need more information and I will be happy to provide the information you need.</p>
  
  <pre><code>&lt;?php
  /**
   * Created by JetBrains PhpStorm.
   * User: Gareth
   * Date: 14/07/13
   * Time: 19:01
   * To change this template use File | Settings | File Templates.
   */
  ini_set('display_errors', 'On');
  error_reporting(E_ALL);
  $news = "";
  
  if ($loggedin === false) { echo "Please log in to access the admin panel."; include_once("login.php"); }
  else {
  
      $uid = $_SESSION['adminid'];
  
      if(isset($_REQUEST['addPackageBtn'])) {
          $packageName = $_POST['inputName'];
          $packageInventory = $_POST['inputInventory'];
          $packageBackpack = $_POST['inputBackpack'];
          $packageSkin = $_POST['inputSkin'];
  
          $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          //$dbh-&gt;query("INSERT INTO `cust_loadout`(`inventory`, `backpack`, `model`, `description`) VALUES ('". $packageInventory ."','". $packageBackpack ."','". $packageSkin ."','". $packageName . "'");
          $dbh-&gt;query("INSERT INTO `cust_loadout` (`inventory`, `backpack`, `model`, `description`) VALUES ([],[],[],[]");
      }
  
      ?&gt;
      &lt;h1&gt;Manage VIP's&lt;/h1&gt;
  
      &lt;table class="table table-striped table-bordered span8"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Delete&lt;/th&gt;
              &lt;th&gt;Unique ID&lt;/th&gt;
              &lt;th&gt;Package&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          &lt;?php
          foreach ($dbh-&gt;query("SELECT * FROM cust_loadout_profile") AS $vip) {
  
          echo "&lt;tr&gt;";
          echo "&lt;td&gt;Delete&lt;/td&gt;";
          echo "&lt;td&gt;".$vip["unique_id"]."&lt;/td&gt;";
          echo "&lt;td&gt;".$vip["cust_loadout_id"]."&lt;/td&gt;";
          echo "&lt;/tr&gt;";
  
  
          }
      ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
      &lt;table class="table table-striped table-bordered span3"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Manage VIP's&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;a href="#addVIP" role="button" data-toggle="modal" class="btn btn-primary"&gt;&lt;i class="icon-white icon-plus-sign"&gt;&lt;/i&gt; Add VIP&lt;/a&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;a href="#addPackage" role="button" data-toggle="modal" class="btn btn-primary"&gt;&lt;i class="icon-white icon-plus-sign"&gt;&lt;/i&gt; Add VIP Package&lt;/a&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
      &lt;table class="table table-striped table-bordered span8"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Delete&lt;/th&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Inventory&lt;/th&gt;
              &lt;th&gt;Backpack&lt;/th&gt;
              &lt;th&gt;Skin&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          &lt;?php
          foreach ($dbh-&gt;query("SELECT * FROM cust_loadout") AS $vip) {
  
              echo "&lt;tr&gt;";
              echo "&lt;td&gt;Delete&lt;/td&gt;";
              echo "&lt;td&gt;".$vip["description"]."&lt;/td&gt;";
              echo "&lt;td&gt;".$vip["inventory"]."&lt;/td&gt;";
              echo "&lt;td&gt;".$vip["backpack"]."&lt;/td&gt;";
              echo "&lt;td&gt;".$vip["model"]."&lt;/td&gt;";
              echo "&lt;/tr&gt;";
  
  
          }
          ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
      &lt;!-- Add VIP Modal --&gt;
      &lt;div id="addVIP" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addVIPLabel" aria-hidden="true"&gt;
          &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
              &lt;h3 id="addVIPLabel"&gt;Add VIP&lt;/h3&gt;
          &lt;/div&gt;
          &lt;div class="modal-body"&gt;
              &lt;form class="form-horizontal"&gt;
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="inputUniqueID"&gt;Unique ID&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input type="text" id="inputUniqueID" placeholder="Unique ID"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="inputPackage"&gt;Package&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input type="text" id="inputPackage" placeholder="Package"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="control-group"&gt;
                      &lt;div class="controls"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
          &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
              &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt;
              &lt;button type="submit" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;!-- Add VIP Package Modal --&gt;
      &lt;div id="addPackage" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addPackagePLabel" aria-hidden="true"&gt;
          &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
              &lt;h3 id="addPackageLabel"&gt;Add VIP Package&lt;/h3&gt;
          &lt;/div&gt;
          &lt;div class="modal-body"&gt;
              &lt;form class="form-horizontal" acion="./?p=admin/vip" method="post"&gt;
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="inputName"&gt;Name&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input type="text" id="inputName" name="inputName" placeholder="Name"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="inputInventory"&gt;Inventory&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input type="text" id="inputInventory" name="inputInventory"  placeholder="Inventory"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="inputBackpack"&gt;Backpack&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input type="text" id="inputBackpack" name="inputBackpack" placeholder="Backpack"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="inputSkin"&gt;Skin&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input type="text" id="inputSkin" name="inputSkin" placeholder="Skin"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;p&gt;Click &lt;a href="./pages/loadoutS/loadout.php" onclick="window.open(this.href, 'mywin',
  'left=20,top=20,width=726px,height=481,toolbar=1,resizable=0'); return false;" &gt;here&lt;/a&gt; to generate a inventory string&lt;/p&gt;
  
          &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
              &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt;
              &lt;button type="submit" name="addPackageBtn" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;?php
  }
  
  ?&gt;
  </code></pre>