title: How to upload images into MySQL database using PHP code
body: <p>I am trying to save images in my database from HTML form. I have written PHP code to accomplish this task. The program is not generating any error message, but also not inserting image data in MySQL database. Kindly check it.
  Here i am sharing a excerpt from my code.</p>
  
  <pre><code>        /*-------------------
      IMAGE QUERY 
      ---------------*/
  
  
      $file   =$_FILES['image']['tmp_name'];
      if(!isset($file))
      {
        echo 'Please select an Image';
      }
      else 
      {
         $image_check = getimagesize($_FILES['image']['tmp_name']);
         if($image_check==false)
         {
          echo 'Not a Valid Image';
         }
         else
         {
          $image = file_get_contents ($_FILES['image']['tmp_name']);
          $image_name = $_FILES['image']['name'];
          if ($image_query = mysql_query ("insert into product_images values (1,'$image_name',$image )"))
          {
            echo $current_id;
           //echo 'Successfull';
          }
          else
          {
            echo mysql_error();
          }
         }
     }
          /*-----------------
      IMAGE QUERY END
      ---------------------*/
  
      &lt;form action='insert_product.php' method='POST' enctype='multipart/form-data' &gt;&lt;/br&gt;
              File        : &lt;input type='file' name= 'image' &gt;
      &lt;/form&gt;
  </code></pre>
  
  <blockquote>
    <p>Error Message
    You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near '' at line 1</p>
  </blockquote>