title: Failed to run query: 1048 Column 'element_oppningar' cannot be null
body: <p>I'm using PHPExcel to import xls to mysql.
  I recently switched connection to PDO.
  But then an error accord.
  Fields in my xls that is NULL are no longer accepted.
  Why? How can i change my code to accept NULL value?</p>
  
  <p>PHP:</p>
  
  <pre><code>if(isset($_POST["Import"])){
  echo '&lt;a href=".php"&gt;Fortsätt...&lt;/a&gt;&lt;br  /&gt;';
  echo $path=$_FILES["file"]["tmp_name"];
  
  //Load file into PHPExcel
  $objPHPExcel = PHPExcel_IOFactory::load($path);
  
  //Loop threw file to get data
  foreach ($objPHPExcel-&gt;getWorksheetIterator() as $worksheet) {
      $worksheetTitle     = $worksheet-&gt;getTitle();
      $highestRow         = $worksheet-&gt;getHighestRow(); // e.g. 10
      $highestColumn      = 'J'; //$worksheet-&gt;getHighestColumn(''); // e.g 'F'
      $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
      $nrColumns = ord($highestColumn) - 64;
  
  //Echo file info
  echo "&lt;br&gt;The worksheet ".$worksheetTitle." has ";
  echo $nrColumns . ' columns (A-' . $highestColumn . ') ';
  echo ' and ' . $highestRow . ' row.';
  echo '&lt;br&gt;Data: &lt;table border="1"&gt;&lt;tr&gt;';
  
  //Loop threw colum, rows and cells
  for ($row = 2; $row &lt;= $highestRow; ++ $row) {
      echo '&lt;tr&gt;';
      for ($col = 0; $col &lt; $highestColumnIndex; ++ $col) {
          $cell = $worksheet-&gt;getCellByColumnAndRow($col, $row);
          $val = $cell-&gt;getCalculatedValue();
          //$dataType = PHPExcel_Cell_DataType::dataTypeForValue($val);
          echo '&lt;td&gt;' . $val . '&lt;br&gt;&lt;/td&gt;';
      }
      echo '&lt;/tr&gt;';
  }
  echo '&lt;/table&gt;';
  }
  
  for ($row = 2; $row &lt;= $highestRow; ++ $row) {
  $val=array();
  for ($col = 0; $col &lt; $highestColumnIndex; ++ $col) {
  $cell = $worksheet-&gt;getCellByColumnAndRow($col, $row);
  $val[] = $cell-&gt;getCalculatedValue();
  }
  // Prepare Query 
      $query = "INSERT INTO table(
                  objekt_nr,
                  objekt_rev,
                  element_nr,
                  element_hojd,
                  element_typ,
                  element_langd,
                  element_oppningar,
                  element_vikt,
                  element_ritare,
                  element_status) 
              VALUES ( 
              :objekt_nr, 
              :objekt_rev, 
              :element_nr,
              :element_hojd,
              :element_typ,
              :element_langd,
              :element_oppningar,
              :element_vikt,
              :element_ritare,
              :element_status
          )"; 
  
      // Security measures
      $query_params = array(  
          ':objekt_nr' =&gt; $val[0],
          ':objekt_rev' =&gt; $val[1],
          ':element_nr' =&gt; $val[2],
          ':element_hojd' =&gt; $val[3],
          ':element_typ' =&gt; $val[4],
          ':element_langd' =&gt; $val[5],
          ':element_oppningar' =&gt; $val[6],
          ':element_vikt' =&gt; $val[7],
          ':element_ritare' =&gt; $val[8],
          ':element_status' =&gt; $val[9]
      ); 
      try {  
          $stmt = $db-&gt;prepare($query); 
          $result = $stmt-&gt;execute($query_params); 
      } 
      catch(PDOException $ex){ die("Failed to run query: " . $ex-&gt;getMessage()); }
  </code></pre>