title: Uploading image into a db and folder
body: <p>I have this problem i've created a code for uploading text and image into a database and a folder. Few days back I was wondering how to create a unique id and to be inserted. I've figured it out a way but then the code doesn't upload the image into the database only into the folder.</p>
  
  <pre><code>&lt;?php
  if (isset($_FILES['files'])) {
      $errors = array();
      foreach ($_FILES['files']['tmp_name'] as $key =&gt; $tmp_name) {
          $file_name = $key . $_FILES['files']['name'][$key];
          $file_size = $_FILES['files']['size'][$key];
          $file_tmp  = $_FILES['files']['tmp_name'][$key];
          $file_type = $_FILES['files']['type'][$key];
          if ($file_size &gt; 2097152) {
              $errors[] = 'File size must be less than 2 MB';
          }
          $query = "
              INSERT INTO image_area2
                  ('id',`name`,`path`,`unique_id`)
              VALUES
                  ('','$file_name','uploads/$file_name','$_POST[un_id]');
          ";
  </code></pre>
  
  <p>The code seems to be fine for the image to be insert into the database but it doesn't work and I can't figure it out. Thank you for the help in advance.</p>
  
  <p>My answears so far so you could see it better:</p>
  
  <ul>
  <li><p>Well the problem is i don't have any error which is the strangest thing. It works perfectly it inserts the text into the db and the image into the folder but it doesn't insert the path and name into the db. And the code for the insertion is ok i think and i can't figure it why it doesn't do it. I've used print_r($query) function to see if the code is receiving the information from the form and it is receiving it.</p></li>
  <li><p>Well i've added the mysql_query($query); row and nothing again it has added the text into the db and the image into the folder but nothig about the image into the db. $_FILES['files']['tmp_name'] i use it to define and get the name,tmp name size and type and i've put them into the array $file_name,$file_size,$file_type and $file_tmp </p></li>
  <li><p>Well i've cleared the id it posted one time but the strange thing is that i've added 1 image and in the db there where 2 lines for the same image and then if i want to add new text and new image again it doesn't work 1 or more images are added into the folder only.</p></li>
  </ul>
  
  <p>RESOLVED:
  The problem was resolved with 2 steps the one that i was written 'id' like that and it wasn't needed anyway and the second the WAMP server was having problems and it was removed and changed. Thank you for all your help :)</p>