Error on uploading file to the db

hostsunleashed

New Member
Messages
5
Reaction score
0
Points
0
Hey,

I am new at programing and I am trying to upload a file into the db but I get the below error


Warning: fopen() [function.fopen]: Filename cannot be empty in /home/leog/public_html/hostsunleashed.net/feedback/feedback.php on line 33

Warning: fread(): supplied argument is not a valid stream resource in /home/leog/public_html/hostsunleashed.net/feedback/feedback.php on line 34

Warning: fclose(): supplied argument is not a valid stream resource in /home/leog/public_html/hostsunleashed.net/feedback/feedback.php on line 36
Error: Column count doesn't match value count at row 1

my code is below


Code:
if(isset($_POST['upload']) && $_FILES['userfile']['size'] >  0)
{

$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}

$sql="INSERT INTO Feedback (Name, Email,Comments, filename, size, type, content)
VALUES
('$_POST[fullname]','$_POST[email]','$_POST[comments]''$_POST[$fileName]''$_POST[$fileSize]''$_POST[$fileType]''$_POST[$content]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
}

mysql_close($con)
Can sme1 help me out?
 

zapzack

New Member
Messages
606
Reaction score
19
Points
0
Warning: fopen() [function.fopen]: Filename cannot be empty in /home/leog/public_html/hostsunleashed.net/feedback/feedback.php on line

That tells the story.. The variable "$tmpName" is returning nothing so "$_FILES['userfile']['tmp_name']" is returning nothing.. make sure that your form script is working correctly..
 
Top