title: Upload file and the file already upload in the folder but why the file did not store in database
body: <p>I have some problem about uploading and database. I upload the file (abc.txt) and the file already insert to the folder name (uploads). But when I check in database (php), it did not enter. Here is my code:</p>
  
  <pre><code>&lt;?php require_once('Connections/sperformance.php');?&gt;
  &lt;?php session_start();
  if(isset($_SESSION['MM_Username']))  
  ?&gt;
  &lt;?php
  error_reporting(0);
  if(isset($_POST['submit']))
  {
      $target = "uploads/"; 
      $allowedExts = array("jpg", "jpeg", "png", "doc", "txt", "JPG", "JPEG", "PNG", "DOC", "TXT", "zip");
      $extension = end(explode(".", $_FILES["file_upload"]["name"]));
      $target = $target . basename( $_FILES['file_upload']['name']);
      $date = date("Y-m-d H:i:s");
  
      //Function to generate image thumbnails
      function make_thumb($src, $dest, $desired_width) {
  
          /* read the source image */
          $source_image = imagecreatefromjpeg($src);
          $width = imagesx($source_image);
          $height = imagesy($source_image);
  
          /* find the "desired height" of this thumbnail, relative to the desired width  */
          $desired_height = floor($height * ($desired_width / $width));
  
          /* create a new, "virtual" image */
          $virtual_image = imagecreatetruecolor($desired_width, $desired_height);
  
          /* copy source image at a resized size */
          imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
  
          /* create the physical thumbnail image to its destination with 100% quality*/
          imagejpeg($virtual_image, $dest,100);
      }
  
      //check for allowed extensions
  
  
  if (($_FILES["file_upload"]["type"] == "image/jpg")|| ($_FILES["file_upload"]["type"] == "image/jpeg") || ($_FILES["file_upload"]["type"] == "image/png")|| ($_FILES["file_upload"]["type"] == "application/msword") || ($_FILES["file_upload"]["type"] == "text/plain")  || ($_FILES["file_upload"]["type"] == " application/octet-stream") &amp;&amp; in_array($extension, $allowedExts))
  
  
      {
          $photoname = $_FILES["file_upload"]["name"];
          if (file_exists("../uploads/" . $photoname))
          {
              die( '&lt;div class="error"&gt;Sorry &lt;b&gt;'. $photoname . '&lt;/b&gt; already upload before this.&lt;/div&gt;');
          }
  
          if(move_uploaded_file($_FILES['file_upload']['tmp_name'], $target)) 
          {
              $query = "INSERT INTO updown (nama_file,tkh_muatnaik) VALUES ('$photoname','$date')";
              mysql_query($query); 
              $sql = "SELECT MAX(id_file) FROM updown";
              $max = mysql_query($sql);
              $row = mysql_fetch_array($max);
              $maxId = $row['MAX(id_file)'];
  
              $type = $_FILES["file_upload"]["type"];
              switch($type)
              {
                  case "image/jpeg":
                  $ext = ".jpeg";
                  break;
                  case "image/jpg";
                  $ext = ".jpg";
                  break;  
                  case "image/png":
                  $ext = ".png";
                  break;
                  case "application/msword":
                  $ext = ".doc";
                  break;
                  case "text/plain":
                  $ext = ".txt";
                  break;      
                  case "application/octet-stream":
                  $ext = ".zip";
                  break;      
              }
  
              if (!in_array($ext, array('.doc', '.txt', '.zip'))) {
              //define arguments for the make_thumb function
              $source = "uploads/".$photoname;
              $destination = "thumbnails/thumb_". $maxId . $ext ."";          
              //specify your desired width for your thumbnails
              $width = "282";
              //Finally call the make_thumb function
              make_thumb($source,$destination,$width);
              }
  
              $msg = '&lt;div class="success"&gt;
                          &lt;br/&gt;&lt;b&gt;Uploaded: &lt;/b&gt;' . basename($photoname) . '&lt;br /&gt;
                          &lt;b&gt;Format: &lt;/b&gt;' . $_FILES["file_upload"]["type"] . '&lt;br /&gt;
                          &lt;b&gt;Size: &lt;/b&gt;' . ceil(($_FILES["file_upload"]["size"] / 1024)) . 'Kb&lt;br /&gt;
                      &lt;/div&gt;';
              }    
              else
              {
                  $msg = '&lt;div class="error"&gt;Sorry, Upload file does not work.&lt;/div&gt;';
              }
          }
          else
          {
              $msg = '&lt;div class="error"&gt;This file format is not accepted!&lt;/div&gt;';
          }
  }
  ?&gt;
  &lt;?php ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;eportfolio-FCSIT&lt;/title&gt;
  &lt;style type="text/css"&gt; 
  &lt;!-- 
  body  {
      font: 100% Verdana, Arial, Helvetica, sans-serif;
      margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
      padding: 0;
      text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
      color: #000000;
      background-color: #CCCCCC;
  }
  
  /* Tips for Elastic layouts 
  1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
  2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
  3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing.
  */
  .twoColElsLtHdr #container {
      width: 65%;  /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
      background: #DBE6F4; /* the auto margins (in conjunction with a width) center the page */
      border: 1px solid #000000;
      text-align: left; /* this overrides the text-align: center on the body element. */
      margin-top: 0;
      margin-right: auto;
      margin-bottom: 0;
      margin-left: auto;
      position: absolute;
      top: 25px;
      left: 232px;
      padding: 10px;
      white-space: normal;
      height: auto;
      bottom: 20px;
      background-color: #DBE6F4;
  } 
  .twoColElsLtHdr #header {
      top: 70px;
      border: thin solid #DBE6F4;
      background-color: #DBE6F4;
  } 
  .twoColElsLtHdr #header h1 {
      margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
      padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
      bottom: 20px;
  }
  
  /* Tips for sidebar1:
  1. Be aware that if you set a font-size value on this div, the overall width of the div will be adjusted accordingly.
  2. Since we are working in ems, it's best not to use padding on the sidebar itself. It will be added to the width for standards compliant browsers creating an unknown actual width. 
  3. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColElsLtHdr #sidebar1 p" rule.
  */
  .twoColElsLtHdr #navigasi {
      float: left;
      width: 228px; /* top and bottom padding create visual space within this div */
      padding-top: 5px;
      padding-bottom: 5px;
      padding-left: 5;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      font-style: normal;
      top: 139px;
      position: absolute;
      text-align: justify;
      white-space: nowrap;
      text-indent: -5px;
      height: 155px;
      line-height: normal;
      border: thin none #76BCE2;
      left: 7px;
  }
  .twoColElsLtHdr #sidebar1 h3, .twoColElsLtHdr #sidebar1 p {
      margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
      margin-right: 10px;
  
  }
  
  
  
  
  /* Tips for mainContent:
  1. If you give this #mainContent div a font-size value different than the #sidebar1 div, the margins of the #mainContent div will be based on its font-size and the width of the #sidebar1 div will be based on its font-size. You may wish to adjust the values of these divs.
  2. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div.  No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
  3. To avoid float drop, you may need to test to determine the approximate maximum image/element size since this layout is based on the user's font sizing combined with the values you set. However, if the user has their browser font size set lower than normal, less space will be available in the #mainContent div than you may see on testing.
  4. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs that may occur.
  */
  .thrColAbsHdr #sidebar2 {
      position: absolute;
      right: 0;
      width: 160px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
      background: #EBEBEB; /* padding keeps the content of the div away from the edges */
      bottom: 100px;
      border: thin dashed #000000;
  }
  
  .twoColElsLtHdr #mainContent {
      left: 86px;
      right: auto;
      margin-top: 0;
      margin-right: 1.5em;
      margin-bottom: 0;
      margin-left: 13em;
      top: 150px;
      bottom: auto;
      padding-bottom: 0px;
      padding-left: 40px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      background-color: #FFFFFF;
      text-align: justify;
      position: absolute;
      width: 609px;
      height: 325px;
      border: thin dashed #76BCE2;
      vertical-align: 20%;
  } 
  .twoColElsLtHdr #footer {
      background-color: #DDDDDD;
      background-image: url(image/footer.jpg);
      width: 884px;
      padding: 5;
      position: absolute;
      bottom: 5px;
  } 
  .twoColElsLtHdr #footer p {
      margin: 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
      bottom: 5px;
      top: 5px;
      padding-top: 5px;
      padding-right: 0;
      padding-bottom: 5px;
      padding-left: 0;
      position: absolute;
  }
  
  /* Miscellaneous classes for reuse */
  .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
      float: right;
      margin-left: 8px;
  }
  .fltlft { /* this class can be used to float an element left in your page */
      float: left;
      margin-right: 8px;
  }
  .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
      clear:both;
      height:0;
      font-size: 1px;
      line-height: 0px;
  }
  #apDiv1 {
      position:absolute;
      width:223px;
      height:188px;
      z-index:1;
      left: 10px;
      top: 333px;
      border: thin dashed #76BCE2;
  }
  #apDiv2 {
      position:absolute;
      width:168px;
      height:115px;
      z-index:1;
      left: 730px;
      top: -181px;
      border: thin dashed #76BCE2;
  }
  .style3 {color: #0000FF}
  #apDiv3 {
      position:absolute;
      width:567px;
      height:195px;
      z-index:1;
      border: thin dashed #76BCE2;
  }
  --&gt; 
  &lt;/style&gt;
  &lt;!--[if IE]&gt;
  &lt;style type="text/css"&gt; 
  /* place css fixes for all versions of IE in this conditional comment */
  .twoColElsLtHdr #sidebar1 { padding-top: 30px; }
  .twoColElsLtHdr #mainContent { zoom: 1; padding-top: 15px; }
  /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
  &lt;/style&gt;
  &lt;![endif]--&gt;
  &lt;script src="Scripts/AC_RunActiveContent.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body class="twoColElsLtHdr"&gt;
  
  &lt;div id="container"&gt;
    &lt;div id="header"&gt;&lt;img src="image/header_baru.jpg" width="880" height="123" alt="header" /&gt;
    &lt;!-- end #header --&gt;&lt;/div&gt;
    &lt;div id="navigasi"&gt;
   &lt;style&gt;
  nav {
      /* Repeating background image */
      background: url(image/Un.png);
      width:215px;
      margin:5px;
  }
  
  nav ul {
      /* Removes bullet points */
      list-style:none;
      margin:0;
      padding:0;
  
  }
  nav ul li {
      /* Any child positioned absolutely will be positioned relative to this */
      border:thin dashed #76BCE2;
      position:relative;
  }
  nav a {
      color:#e8e8e8;
      padding:10px 0px;
      /* Fill all available horizontal space */
      display:block;
      /* Remove underline */
      text-decoration:none;
      /* 
      New CSS3 animations:
      apply transition to background property, taking 1s to change it 
      */
      transition:background 1s;
      -moz-transition:background 1s;
      -webkit-transition:background 1s;
      -o-transition:background 1s;
      font-family:arial;
      font-size:12px;
      text-transform:uppercase;
      padding-left:15px;
  }
  nav a:hover {
      /* 
      RGBA background for transparancy: 
      last number(0.05) is the transparency 
      */
      background: RGBA(255,255,255,0.05);
      color:#fff;
  
  }
  nav a:hover span {
      background: #009999;
      transform:rotate(90deg);
      -moz-transform:rotate(90deg);
      -webkit-transform:rotate(90deg);
  }
  nav ul li:hover ul {
      display:block;
  }
  nav ul ul {
      position:relative;
      bottom:210px;
      top:0;
      border-top:0px solid #e9e9e9;
      display:none;
  }
  nav ul ul li {
      width:211px;
      background:#f1f1f1;
      border:1px solid #e9e9e9;
      border-top:0;
  }
  nav ul ul li a {
      color:#a8a8a8;
      font-size:12px;
      text-transform:none;
  }
  nav ul ul li a:hover {
      color:#0000FF;
  }
  nav span {
      width:12px;
      height:12px;
      background:#fff;
      display:inline-block;
      float:left;
      margin-top:3px;
      margin-right:20px;
      position:relative;
      transition:all 0.5s;
      -moz-transition:all 0.5s;
      -o-transition:all 0.5s;
      -webkit-transition:all 0.5s;
  }
  nav span:before {
      content:"";
      width:12px;
      height:2px;
      background:#76BCE2;
      position:absolute;
      left:0px;
      top:5px;
  }
  nav span:after {
      content:"";
      width:2px;
      height:12px;
      background:#76BCE2;
      position:absolute;
      left:5px;
      position:top;
  }
  
  &lt;/style&gt;
  &lt;nav&gt;&lt;a href="student_home.php"&gt;&lt;span&gt;&lt;/span&gt; Home &lt;/a&gt;
    &lt;ul&gt;&lt;li&gt; &lt;a href="student_profile.php"&gt;&lt;span&gt;&lt;/span&gt;Profile&lt;/a&gt;
                      &lt;/li&gt;
          &lt;li&gt; &lt;a href="student_portfolio.php"&gt;&lt;span&gt;&lt;/span&gt;Portfolio &lt;/a&gt;
  
          &lt;/li&gt;
      &lt;li&gt; &lt;a href="student_academic.php"&gt;&lt;span&gt;&lt;/span&gt;Academic Performance &lt;/a&gt;
          &lt;ul&gt;
                  &lt;li&gt;&lt;a href="student_feedback.php"&gt;Comment / Feedback &lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
  
        &lt;/li&gt;
          &lt;li&gt; &lt;a href="stu_logout.php"&gt;&lt;span&gt;&lt;/span&gt;Logout &lt;/a&gt;
      &lt;/ul&gt;
      &lt;/li&gt;
  &lt;/nav&gt;
  
    &lt;/div&gt;
    &lt;div id="mainContent"&gt;
    &lt;p class="style3"&gt;Welcome, &lt;?php echo $_SESSION['MM_Username']?&gt;
  &lt;h1 align="center"&gt;  Upload Portfolio&lt;/h1&gt;
  
  
  
     &lt;div id="apDiv3"&gt;
     &lt;body&gt;
  &lt;table width="86%"  align="center"&gt;
  &lt;tr&gt;
  &lt;td colspan="2" class="header"&gt;&lt;/td&gt;
  &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width="79%"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;H3 class="main_title"&gt;Upload file.&lt;/H3&gt;
        (&lt;a href="student_download.php" &gt;List File&lt;/a&gt;)
        &lt;div id="upload"&gt;
  &lt;?php echo $msg; ?&gt;
  &lt;form action="" method="post" enctype="multipart/form-data"&gt;
  &lt;br /&gt;&lt;label for="file"&gt; File:&lt;/label&gt;
  &lt;input type="file" name="file_upload" id="upload_file" /&gt;&lt;br /&gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
  &lt;input type="submit" name="submit" value="Upload" /&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --&gt;&lt;br class="clearfloat" /&gt;
    &lt;div id="footer"&gt;
      &lt;div align="center"&gt;&lt;font size="1"&gt;
  &lt;strong&gt;&lt;br /&gt;
  &lt;/strong&gt;Copyright &amp;copy; 2013 FACULTY OF  COMPUTER SCIENCE &amp;amp; INFORMATION TECHNOLOGY( FCSIT).&lt;br /&gt;
  Universiti Malaysia Sarawak, 94300 Kota Samarahan, Sarawak, Malaysia Telephone: +60 82581000/+60 82581388, Fax: +60 82 665 088&amp;nbsp;&lt;br /&gt;
  &lt;br&gt;
      &lt;/font&gt;&lt;/div&gt;
    &lt;!-- end #footer --&gt;&lt;/div&gt;
  &lt;!-- end #container --&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Hope anyone can help me.Thank you.</p>