title: Error in displaying an image in php mysql
body: <p>Hey I am facing a problem in displaying images in php. The images are being stored in a table 'images' in mysql. There is another table 'restaurant' which needs to fetch those images and display respective images according to the restid. However, it is facing a problem in fetching the images and not displaying them. Please help!
  This is imageupload.php:</p>
  
  <pre><code>&lt;?php
  require 'connect.inc.php';
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Uploading image&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  echo "&lt;form action='imageupload.php' method='POST' enctype='multipart/form-data'&gt;
  
  Upload: &lt;input type='file' name='image'&gt;&lt;input type='submit' value='Upload' &gt;
  &lt;/form&gt;";
  
  if(isset($_FILES['image']['tmp_name']))
  
  {
      $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
      {
          $query = "INSERT INTO images VALUES ('','$image_name','$image','22')";
          $result = mysqli_query($con, $query);
  
          if(!$result)
          {
              echo "Problem uploading";
  
          }
          else
          {
              echo "Image uploaded ";
              $query2 = "SELECT * FROM images WHERE restid = '22'";
              $result2 = mysqli_query($con,$query2);
              while($info = mysqli_fetch_array($result2))
              {
                  header("Content-type: image/jpeg");
                  echo $info['image'];
              }
          }
      }
  }
  else
  {
      "Please upload a file";
  }
   ?&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>This is getimage.php (It fetches the image and displays it):</p>
  
  <pre><code>&lt;?php
  require 'connect.inc.php';
  $id = $_REQUEST['id'];
  $image = "SELECT * FROM images WHERE imgid = $id" ;
  $image = mysqli_query($con, $image);
  $image = mysqli_fetch_assoc($image);
  $image = $image['image'];
  
  header("Content-type: image/jpeg");
  echo $image;
  ?&gt;
  </code></pre>
  
  <p>connect.inc.php is a file to connect to the database. I referred to other links but did not get any solid help. Please provide help.</p>