title: Getting an image from a database using PHP
body: <p>first time using stack overflow.</p>
  
  <p>I have followed the following 2 part youtube tutorial on uploading/storing an image in a MYSQL database. I have followed the instructions but my image is not appearing for me. I use connect.php to connect to the database, this appears to be working fine. It seems the problem is with get.php as when I test echoing any images from it I always get no image.
   used phpmyadmin to create the database and am using xampp.</p>
  
  <p>here is the link to the youtube tutorials</p>
  
  <p><a href="http://www.youtube.com/watch?v=CxY3FR9doHI" rel="nofollow">http://www.youtube.com/watch?v=CxY3FR9doHI</a></p>
  
  <p><a href="http://www.youtube.com/watch?v=vFZfJZ_WNC4&amp;feature=fvwrel" rel="nofollow">http://www.youtube.com/watch?v=vFZfJZ_WNC4&amp;feature=fvwrel</a></p>
  
  <p>Included are the files</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Upload an image&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="index.php" method="POST" enctype="multipart/form-data"&gt;
      File:   
  &lt;input type="file" name="image"&gt; &lt;input type="submit" value="Upload"&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  include 'connect.php';
  
  
  
  //file properties
  $file = $_FILES['image']['tmp_name'];
  
  if(!isset($file))
      echo "Please select an image.";
  else{
  
      $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
      $image_name=addslashes($_FILES['image']['name']);
      $image_size = getimagesize($_FILES['image']['tmp_name']);
  
      if ($image_size==FALSE)
          echo "That's not an image.";
      else{
              if(!$insert = mysql_query("INSERT INTO store       VALUES('','$image_name','$image')"))
          echo"Problem uploading image";
      else{
          $lastid = mysql_insert_id();
  
          echo "image uploaded.&lt;p /&gt;your image:&lt;p /&gt;&lt;img src=get.php?id=$lastid&gt;";
          }
      }
  }
  
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is get.php</p>
  
  <pre><code>&lt;?php
  include 'connect.php';
  
  $id=stripslashes($_REQUEST('id'));
  $image = mysql_query("SELECT * FROM store WHERE id=$id");
  $image = mysql_fetch_assoc($image);
  $image=$image('image');
  
  header("content-type: image/jpeg");
  
  
  ?&gt;
  </code></pre>
  
  <p>And finally connect</p>
  
  <pre><code>&lt;?php
  // connect to database
  
  $db_host="localhost";
  $db_username="root";
  $db_pass="";
  $db_name="test";
  
  @mysql_connect("$db_host","$db_username","$db_pass") or die("Could not connect to      mysql");
  mysql_select_db("$db_name")or die("Cant find database");
  
  ?&gt;
  </code></pre>