title: Trying to Update MySQL database (uploading file) using a php script
body: <p>I am trying to create a login system where users can upload file in the existing database. First require the user to login then upload file. Here is my database:
  <a href="https://i.stack.imgur.com/SMymY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SMymY.png" alt="enter image description here"></a></p>
  
  <p>Now I want to update cv (blob).
  So I have created the following page.</p>
  
  <pre><code>&lt;!-- Form --&gt;
  
  &lt;h1&gt;Pease Login to Upload CV&lt;/h1&gt;
  &lt;form method="POST" enctype="multipart/form-data"&gt;
      Username:
      &lt;input type="text" name="username"&gt;&lt;br&gt;
      Password:
      &lt;input type="password" name="password"&gt;&lt;br&gt;&lt;br&gt;
      &lt;input type="submit" value="Submit" name="submit" /&gt; &lt;br&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>
  Above is the initial form. Then I used the following script:</p>
  
  <pre><code>&lt;!-- Script --&gt;
  &lt;?php 
      if (isset($_POST['submit'])) {
  
  
      // make connection
          $conn = mysqli_connect('localhost','root','','users');
  
  
          // if fails show error
          if (!$conn) {
              die("Connection failed: " . mysqli_connect_error());
              echo "Error Connecting to DB";
          }
  
  
          $usrName = ($_POST['username']);
          $paswrd  = ($_POST['password']);
  
          if($usrName!='' &amp;&amp; $paswrd!=''){
  
              $sql ="SELECT username, password FROM credentials WHERE username = '$usrName'"; 
  
              $result = mysqli_query($conn, $sql);
  
              $row = mysqli_fetch_row($result);
              $dbUsname = $row[0];
              $dbPassword = $row[1];
  
                  if ($usrName == $dbUsname &amp;&amp; $paswrd == $dbPassword) {
                      echo "Hello ".$usrName." upload your CV now &lt;br&gt;";
  
                      echo 
  
                      "&lt;form method='POST' enctype='multipart/form-data'&gt;
                      &lt;input type = 'file' value= 'upload' name = 'file'&gt;
                      &lt;input type='submit' value='Upload' name='upload' /&gt; &lt;br&gt;
                      &lt;/form&gt;";
  
  
  
                      if(isset($_POST['upload'])){
  
                          $cv = mysqli_real_escape_string($conn, $_POST['file']);
  
                          mysql_query("UPDATE credentials SET cv=$cv  WHERE username=$usrName");
  
                          if (!mysqli_query($conn,$UpdateQuery)) {
                              die('Error: ' . mysqli_error($conn));
                          }
  
                      }
  
  
  
                  }
                  else{
                      echo "&lt;h1&gt;Incorrect Username and/or password!&lt;/h1&gt;";
                  }
          }else{
              echo "Please make sure username and password is not empty";
          }
      }
  ?&gt;
  </code></pre>
  
  
  
  <p>I have tested out the script for the most part. The problem occurs when I try to update the cv file. On the code below.
  <a href="https://i.stack.imgur.com/FJOsK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FJOsK.png" alt="enter image description here"></a></p>
  
  <p>The Script executes but I can not see any file uploaded in my database.
  Can someone please point out where am I making the error.</p>