title: PHP MySQL can't find my image from Database
body: <p>Im working on a blog site for school where i have to make a posting system with PHP MySQL. I'm now trying to add images to my post, I've already made a image uploader and its completly working. Now i want to make an option button to choose which image i want at a specific blog post, so i tried to make an option button which would show me all the image names i had in my Database, but now it doesnt say anything and the code stops working after my php code in my form. It shows the Title, body and category but then shows an empty option box. The submit button is not showing aswell.</p>
  
  <p>I hope someone could help me out with this problem im having!</p>
  
  <p>I cant post images yet so i'll tell what my DB names are,
  image_id   //id of the image
  name       //name of the image
  image      //blob</p>
  
  <p>I've also put the image_id in my 'post' table.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;?php
  session_start();
  if(!isset($_SESSION['user_id'])){
      header('Location: login.php');
      exit();
  }
  
  include('../includes/db_connection.php');
  if(!isset($_SESSION['user_id'])){
      header('Location: login.php');
      exit();
  }
  
  if(isset($_POST['submit'])){
      //get the blog data
      $title = $_POST['title'];
      $body = $_POST['body'];
      $category = $_POST['category'];
      $image = $_POST['name'];
          //link everything to the db
          $title = $db-&gt;real_escape_string($title);
          $body = $db-&gt;real_escape_string($body);
          $user_id = $_SESSION['user_id'];
          $date = date('Y-m-d G:i:s');
          $body = htmlentities($body);
      //check if all of these are there
      if($title &amp;&amp; $body &amp;&amp; $category &amp;&amp; $image){
          //place data back into the database
          $query = $db-&gt;query("INSERT INTO posts (user_id, title, body, category_id, image_id, posted) VALUES('$user_id', '$title', '$body', '$category', '$image', '$date')");
          if($query){
              echo "post added";
          }
          else{
              echo "error";
          }
      }
      else{
          echo "MISSING DATA";
      }
  }
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"/&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=9"/&gt;
          &lt;title&gt; Portfolio Sander Mateijsen &lt;/title&gt;
              &lt;style&gt;
              #wrapper{
                  margin: auto;
                  width: 800px;
              }
              label(display:block)
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
  
      &lt;div id="wrapper"&gt;
          &lt;div id="content"&gt;
                  &lt;form action="&lt;?php echo $_SERVER["PHP_SELF"]?&gt;" method="post"&gt;
                      &lt;label&gt;Titel:&lt;/label&gt;&lt;br&gt;&lt;input type="text" name="title" /&gt;&lt;br&gt;
                      &lt;label for="body"&gt; Body:&lt;/label&gt;&lt;br&gt;
                      &lt;textarea name="body" cols=50 rows=10&gt;&lt;/textarea&gt;&lt;br&gt;
                      &lt;label&gt; Category:&lt;/label&gt;&lt;br&gt;
                      &lt;select name="category"&gt;
                          &lt;?php 
                              //display categories from the database as options
                              $query = $db-&gt;query("SELECT * FROM categories");
                              while($row = $query-&gt;fetch_object()){
                                  echo "&lt;option value='".$row-&gt;category_id."'&gt;".$row-&gt;category."&lt;/option&gt;";
                              }
                          ?&gt;
                      &lt;/select&gt;
                      &lt;label&gt; Image:&lt;/label&gt;&lt;br&gt;
                      &lt;select name="name"&gt;
                          &lt;?php 
                              //display images from the database as options
                              $query = $db-&gt;query("SELECT * FROM blob");
                              while($row = $query-&gt;fetch_object()){
                                  echo "&lt;option value='".$row-&gt;image_id."'&gt;".$row-&gt;name."&lt;/option&gt;";
                              }
                          ?&gt;
                      &lt;/select&gt;
                      &lt;br&gt;&lt;br&gt;
                      &lt;input type="submit" name="submit" value="submit" /&gt;
                  &lt;/form&gt;
                  &lt;a href="overzicht_post.php"&gt; Terug naar overzicht.&lt;/a&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>