diff --git a/include/class.file.php b/include/class.file.php
index b9210fccefe9c4d7c198b700d85eff155d0bfa4c..340f4a63d44bfe870b52adbdeca7110575230a4f 100644
--- a/include/class.file.php
+++ b/include/class.file.php
@@ -357,7 +357,7 @@ class AttachmentFile {
                 $file['key'] = $key;
         }
 
-        if (isset($file['size'])) {
+        if (isset($file['size']) && $file['size'] > 0) {
             // Check and see if the file is already on record
             $sql = 'SELECT id, `key` FROM '.FILE_TABLE
                 .' WHERE signature='.db_input($file['signature'])
@@ -365,7 +365,7 @@ class AttachmentFile {
 
             // If the record exists in the database already, a file with the
             // same hash and size is already on file -- just return its ID
-            if (list($id, $key) = db_fetch_row(db_query($sql))) {
+            if (list($id, $key) = db_fetch_row(db_query($sql, false))) {
                 $file['key'] = $key;
                 return $id;
             }