title: Why am I getting a null with my program, returning 0 as an Id in the database
body: <p>The SQL, this is a lot of code, so perhaps this is not the only issue.  </p>
  
  <p>SQL</p>
  
  <pre><code>public function save(): int
      {
          $pdo = Database::connect();  // note the static method call
  
          $sql = "INSERT INTO `boat` VALUES(null,:name, :reg_num, :length, :image, :owner_id)";
          $statement = $pdo-&gt;prepare($sql);
          //$statement-&gt;bindParam(':id', $getId, PDO::PARAM_INT);
          $statement-&gt;bindParam(':name', $this-&gt;name, PDO::PARAM_STR);
          $statement-&gt;bindParam(':reg_num', $this-&gt;regNumber, PDO::PARAM_STR);
          $statement-&gt;bindParam(':length', $this-&gt;length, PDO::PARAM_INT);
          $statement-&gt;bindParam(':image', $this-&gt;image, PDO::PARAM_STR);
          $statement-&gt;bindParam(':owner_id', $this-&gt;ownerId, PDO::PARAM_INT);
  
          if ($statement-&gt;execute()) {
              return 1;
          } else {
              return 0;
          };
  </code></pre>
  
  <p>The HTML and PHP, the database is not processing the id and owner_id fields, I end up with a 0 in both of these columns and an error occurs.</p>
  
  <p>Page 1</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Upload&lt;/title&gt;
          &lt;h1&gt;New boat&lt;/h1&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="add_boat_save.php" method="post"&gt;
              Choose owner:&lt;br&gt;
              &lt;?php
  
              function __autoload($class_name) {
                  include $class_name . '.php';
              }
  
              // MAKE NEW owner object
              $owner = new owner(0, "", 0, 0, "", 0);
  
              $owners = Owner::findAll();
  
              echo "&lt;select name='owner_id'&gt;";
                  foreach ($owners as $owner) {
  
                      echo "&lt;option value='" . $owner-&gt;getId() . "''&gt;" . $owner-&gt;getFirstName() . " ". $owner-&gt;getLastName() ."&lt;/option&gt;";
                  }
                  echo "&lt;/select&gt;";
  
              ?&gt;
              &lt;br&gt;
              Boat name:&lt;br&gt;
              &lt;input type="text" name="name"&gt;&lt;br&gt;
              Boat reg_num:&lt;br&gt;
              &lt;input type="text" name="reg_num"&gt;&lt;br&gt;
              Boat length:&lt;br&gt;
              &lt;input type="text" name="length"&gt;&lt;br&gt;
              image of Boat:&lt;br&gt;
              &lt;select name="image" id="image"&gt;&lt;br&gt;
                  &lt;option value="" selected="selected"&gt;&lt;/option&gt;
              &lt;?php
  
              $dir = "../extracted/images";//your path
              $dh  = opendir($dir);
              while (false !== ($filename = readdir($dh))) {
              $files[] = htmlentities($filename);
              }
              sort($files);
              foreach($files as $filename) {
              echo "&lt;option value='" . $filename . "'&gt;".$filename."&lt;/option&gt;";}
  
              ?&gt;
              &lt;/select&gt;
              &lt;br&gt;
              &lt;input type="submit" name="submit" value="Submit"/&gt;
              &lt;?php
              echo "&lt;br&gt;&lt;br&gt;";
              echo "Click here to return";
              echo "&lt;p&gt;&lt;a href='index.php'&gt;[ BOAT DATABASE ]&lt;/a&gt;&lt;/p&gt;";
              echo "Click here to add an owner";
              echo "&lt;p&gt;&lt;a href='add_owner.php'&gt;[ ADD OWNER HERE ]&lt;/a&gt;&lt;/p&gt;";
              ?&gt;
          &lt;/form&gt;
          &lt;?php
  
          $dir_path = "icons/boat/";
          $extensions_array = array('jpg','png','jpeg');
  
          if(is_dir($dir_path))
          {
              $files = scandir($dir_path);
  
              for($i = 0; $i &lt; count($files); $i++)
              {
                  if($files[$i] !='.' &amp;&amp; $files[$i] !='..')
                  {
  
                      // get file extension
                      $file = pathinfo($files[$i]);
                      $extension = $file['extension'];
  
                      // check file extension
                      if(in_array($extension, $extensions_array))
                      {
                          // show image
                          echo "&lt;img src='$dir_path$files[$i]' height=\"360\" .
                       IMG STYLE=\"position:absolute; TOP:70px; LEFT:280px; \" SRC=\"getImage\"&gt;";
                      }
                  }
              }
          }
  
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Page 2</p>
  
  <pre><code>&lt;?php
  /**
   * Created by PhpStorm.
   * User: Josh
   * Date: 3/4/2017
   * Time: 4:47 PM
   */
  
  // Declare an autoloader
  function __autoload($class_name) {
      include $class_name . '.php';
  }
  
  echo "&lt;h1&gt;Boat saved to database&lt;/h1&gt;";
  
  var_dump($length);
  var_dump($ownerId);
  
  // MAKE NEW boat object
  
  //$id = intval ($_POST['id']);
  $name = filter_var($_POST['name'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
  $regNumber = filter_var ($_POST['reg_num'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
  $length = filter_var(intval($_POST['length'],FILTER_SANITIZE_NUMBER_INT));
  $image = filter_var($_POST['image'],FILTER_SANITIZE_FULL_SPECIAL_CHARS);
  $ownerId = filter_var(intval($_POST['owner_id'],FILTER_SANITIZE_NUMBER_INT));
  
  $save_boat = new Boat(null, "$name", "$regNumber", $length, "$image", $ownerId);
  ?&gt;
  
  &lt;?php
  
  $dir_path = "icons/saved/";
  $extensions_array = array('jpg','png','jpeg');
  
  if(is_dir($dir_path))
  {
      $files = scandir($dir_path);
  
      for($i = 0; $i &lt; count($files); $i++)
      {
          if($files[$i] !='.' &amp;&amp; $files[$i] !='..')
          {
  
              // get file extension
              $file = pathinfo($files[$i]);
              $extension = $file['extension'];
  
              // check file extension
              if(in_array($extension, $extensions_array))
              {
                  // show image
                  echo "&lt;img src='$dir_path$files[$i]' height=\"200\" .
                       IMG STYLE=\"position:absolute; TOP:92px; LEFT:280px; \" SRC=\"getImage\"&gt;";
              }
          }
      }
  }
  
  // INSERT - TO BE IMPLEMENTED !!
  echo "Inserting now&lt;br&gt;";
  $save_boat-&gt;save();
  echo "&lt;br&gt;";
  echo "Click here to add a boat";
  echo "&lt;p&gt;&lt;a href='add_boat.php'&gt;[ ADD BOAT HERE ]&lt;/a&gt;&lt;/p&gt;";
  echo "Click here to add an owner";
  echo "&lt;p&gt;&lt;a href='add_owner.php'&gt;[ ADD BOAT HERE ]&lt;/a&gt;&lt;/p&gt;";
  echo "Click here to return";
  echo "&lt;p&gt;&lt;a href='index.php'&gt;[ BOAT DATABASE ]&lt;/a&gt;&lt;/p&gt;";
  </code></pre>