+ Reply to Thread
Results 1 to 2 of 2
Like Tree2Likes
  • 2 Post By hostsunleashed

Thread: Error on uploading file to the db

  1. #1
    hostsunleashed is offline x10Hosting Member hostsunleashed is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    5

    Red face Error on uploading file to the db

    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?
    dinomirt96 and karimirt47 like this.

  2. #2
    zapzack is offline x10 Elder zapzack is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    606

    Re: Error on uploading file to the db

    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..

+ Reply to Thread

Similar Threads

  1. It works! ...
    By bpakidz in forum Programming Help
    Replies: 4
    Last Post: 09-07-2008, 11:12 PM
  2. Internal Serve Error
    By xaakx in forum Free Hosting
    Replies: 6
    Last Post: 02-03-2008, 08:02 AM
  3. help!!
    By retro-bliss in forum Free Hosting
    Replies: 25
    Last Post: 12-07-2007, 01:12 PM
  4. Replies: 8
    Last Post: 12-03-2007, 04:12 PM
  5. php version
    By loveispoison in forum Free Hosting
    Replies: 10
    Last Post: 11-21-2007, 10:53 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers