title: How to upload image and save path to database?
body: <p>I have a page where some images are shown (database driven). Here is the code of my gallery.php :</p>
  
  <pre><code>&lt;ul id="portfolio-list" class="gallery"&gt;
      &lt;?php
          $sql="select * from eikones ";
          $res=mysql_query($sql);
          $count=mysql_num_rows($res);
  
          for ( $i = 0; $i &lt; $count; ++$i )
          {
              $row = mysql_fetch_array( $res );
              $co=$i+1;
              if(isset($row[ "path" ]))
              {
                  $path= $row[ "path" ];
              }
  
              if(isset($row[ "auxon" ]))
              {
                  $auxon = $row[ "auxon" ];
              }
  
  
              if($_SESSION['role'] == "admin")
                  echo "&lt;li class=\"pink\"&gt;&lt;a href=\"$path\" rel=\"group1\" class=\"fancybox\" title=\"Προιόν \"&gt;&lt;img src=\"$path\" alt=\"Pic\"&gt;&lt;/a&gt;&lt;/li&gt;\n";
  
          }
  
          ?&gt;
  
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>Now I want to have a form where I will be able to upload an image. I am trying this but it doesn't work :</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="gallery.php" method="post" name="changer"&gt;
  &lt;input name="image" accept="image/jpeg" type="file"&gt;
  &lt;input value="Submit" type="submit"&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  include 'conf.php'; //database connect
  
  if (isset($_FILES['image']) &amp;&amp; $_FILES['image']['size'] &gt; 0) { 
  
  
    $tmpName  = $_FILES['image']['tmp_name'];  
  
  
    $fp      = fopen($tmpName, 'r');
    $data = fread($fp, filesize($tmpName));
    $data = addslashes($data);
    fclose($fp);
  
  
    $query = "INSERT INTO eikones"; //table name = "eikones" and it has two columns named "auxon" and "path". The auxon is the id.
    $query .= "(image) VALUES ('','$data')";
    $results = mysql_query($query, $link) or die(mysql_error());
  
    print "DONE";
  
    }
    else {
    print "NO IMAGE SELECTED";
    }
  
  ?&gt;
  </code></pre>
  
  <p>It says "NO IMAGE SELECTED" and nothing new comes into the database.</p>