php can't display images
<p>I can successfully upload images in my DB but when I want to display them in my application there is a problem with the images. Here is part of my code:</p>

<p>Edit: Added and add_image.php</p>

<p>index.php</p>

<pre><code>&lt;?php
  session_start();
  include("config.php"); 

  $query = mysql_query("SELECT * FROM images");
  $numrows = mysql_num_rows($query);

  if($numrows != 0) {

    while($row = mysql_fetch_assoc($query)) {
    $title = $row['TITLE'];
    $id = $row['ID'];
    $image = $row['IMAGE'];
    echo $title;
    echo "&lt;img src=image.php?id=$id&gt;";
    echo("&lt;hr/&gt;&lt;br/&gt;&lt;br/&gt;");
  }

  } else {
    die("ERROR");
  }

?&gt;
</code></pre>

<p>image.php</p>

<pre><code>&lt;?php
  include("config.php"); 

  $id = (int)$_REQUEST['id'];

  $image = "SELECT * FROM images WHERE ID = $id";
  $image = mysql_query($image) or die('Error, query failed');
  $image = mysql_fetch_assoc($image);
  $image = $image['image'];
  header("Content-type: image/jpeg");
  echo $image;
?&gt;
</code></pre>

<p>add_image.php</p>

<pre><code>&lt;?php
  session_start();

  $title = $_POST[title]; 

  if(isset($_POST['upload']) &amp;&amp; $_FILES['userfile']['size'] &gt; 0) {
    $fileName = $_FILES['userfile']['name'];
    $tmpName  = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];

    $fp = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);

    if(!get_magic_quotes_gpc()) {
      $fileName = addslashes($fileName);
    }

    include("config.php"); 

    $query = "INSERT INTO images (TITLE,IMAGE) VALUES ('$title','$content')";

    mysql_query($query) or die('Error, query failed'); 

    echo "&lt;br&gt;File $fileName uploaded&lt;br&gt;";
  } 
?&gt;
</code></pre>
