Why I cannot upload an image to a database? : <p>I am having a big trouble when trying to upload an image (using <code>PHP</code>) to a database (<code>phpMyAdmin</code>). Everything seems fine to me even debugging (using <code>eclipse</code>).
When I run my code the image is uploaded, the SQL-query is launched and the image is moved from the tmp-folder. But nothing in my database. Here is the code:</p>

<pre><code>if (isset($_FILES['upload']) &amp;&amp; $_FILES['upload']['size'] &gt; 0) {
    $file = $_FILES['upload']['tmp_name'];
    $name = $_FILES['upload']['name'];
    $type = $_FILES['upload']['type'];
    $size = $_FILES['upload']['size'];

    if (is_uploaded_file($file)) {
        $data = file_get_contents($file);
        $img-&gt;uploadImg($size, $type, $name, $data);
    }
    $older = getcwd () . '/image/'. basename($name);
    move_uploaded_file($_FILES['upload']['tmp_name'], $folder);
}
</code></pre>

<p>And:</p>

<pre><code>  public function uploadImg($size, $mimetype, $filename, $code) {
            try {
                $sql = "INSERT INTO img_table(fileName, size, mimetype, code) VALUES ($filename, $size, $mimetype, $code)";
                $this-&gt;db-&gt;exec($sql);
            }
            catch (PDOException $e) {
                echo $sql.' '.$e-&gt;getMessage();
            }
}
</code></pre>

<p>Any idea or hint to tell me where I am doing wrong. i am open to any suggestions.</p>
