title: Problem with showing image from the database
body: <p>I need a help regarding my source code on uploading and displaying the profile picture of my users on their profile.
  The upload went smooth, but the display is not. The display of the user's picture is only shown in picture icon and not the real picture. Like this:</p>
  
  <p><a href="https://i.stack.imgur.com/AvaM2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AvaM2.png" alt="enter image description here"></a></p>
  
  <p>the file where the picture is stored is here
  <a href="https://i.stack.imgur.com/wug1e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wug1e.png" alt="enter image description here"></a></p>
  
  <p>and here is my source code</p>
  
  <p>edit-profile.php</p>
  
  <pre><code>&lt;div class="author"&gt;
  &lt;a href="#"&gt;
  &lt;img class="avatar border-gray" src="../uploads/candidate/&lt;?php echo $row['photo']; ?&gt;" alt="..."/&gt;
   &lt;h4 class="title"&gt;&lt;?php echo $_SESSION['name']; ?&gt;&lt;br /&gt; &lt;/h4&gt;
   &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I'll provide the full source code for both userindex.php and edit-profile.php here so maybe any of you can point me where I do wrong.</p>
  
  <p>userindex.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>        &lt;div class="content"&gt;
              &lt;div class="container-fluid"&gt;
                  &lt;div class="row"&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;div class="card"&gt;
                              &lt;div class="header"&gt;
                                  &lt;h4 class="title"&gt;Edit Profile&lt;/h4&gt;
                              &lt;/div&gt;
                              &lt;div class="content"&gt;
                                  &lt;form action="update-profile.php" method="post" enctype="multipart/form-data"&gt;
                                     
          &lt;?php
          //Sql to get logged in user details.
          $sql = "SELECT * FROM users WHERE id_user='$_SESSION[id_user]'";
          $result = $conn-&gt;query($sql);
  
          //If user exists then show his details.
          if($result-&gt;num_rows &gt; 0) {
          while($row = $result-&gt;fetch_assoc()) {
          ?&gt;
          &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label for="user_name" type="text" id="user_name"&gt; Full Name&lt;/label&gt;
            &lt;input name="user_name" class="form-control" type="text" maxlength="100" value="&lt;?php echo $row['user_name'] ?&gt;" required=""/&gt; 
                                          &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
           
          &lt;!-- section 1--&gt; 
          
          &lt;div class="row"&gt;
           &lt;div class="col-md-6"&gt;
                                      &lt;div class="form-group"&gt;
                                      &lt;label for="ic_no" type="text" id="ic_no" maxlength="12"&gt;NRIC&lt;/label&gt;
           &lt;input name="ic_no"type="text" class="form-control" value="&lt;?php echo $row['ic_no'] ?&gt;" readonly&gt;
                                       &lt;/div&gt;
                                       &lt;/div&gt;
                                          
          &lt;div class="col-md-6"&gt;
                                       &lt;div class="form-group"&gt;
                                       &lt;label for="nationality" type="text" id="nationality"&gt;Nationality&lt;/label&gt;
                                       &lt;input name="nationality" class="form-control" type="text" id="nationality" value="&lt;?php echo $row['nationality'] ?&gt;"/&gt;
                                          &lt;/div&gt;
                                         &lt;/div&gt;
                                      &lt;/div&gt;
  
           &lt;!--first section --&gt;
           
                                      &lt;div class="row"&gt;
                                          &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="gender" type="text" id="gender"&gt;Gender&lt;/label&gt;
                                                  &lt;input  name="gender" class="form-control" type="text" id="gender" value="&lt;?php echo $row['gender'] ?&gt;"/&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                         
              &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="race" type="text" id="race"&gt;Race&lt;/label&gt;
                                                  &lt;input type="text" class="form-control" name="race" id="race" value="&lt;?php echo $row['race'] ?&gt;"/&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
  
           &lt;!-- second section --&gt;
           
            &lt;div class="row"&gt;
                                          &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="contactno" type="text" id="contact_no"&gt;Contact No&lt;/label&gt;
                                                  &lt;input  name="contactno" class="form-control" type="text" id="contact_no" value="&lt;?php echo $row['contactno'] ?&gt;"&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                         
              &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="email" type="text" id="email"&gt;Email&lt;/label&gt;
                                                  &lt;input type="text" class="form-control" type="text" id="email" value="&lt;?php echo $row['email'] ?&gt;" readonly&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt; 
           
           &lt;!--other add --&gt;
           
                                      &lt;div class="row"&gt;
                                          &lt;div class="col-md-12"&gt;
                                              &lt;div class="form-group"&gt;
                                          &lt;label for="address" type="text" id="address"&gt;Current Address&lt;/label&gt;
            &lt;textarea id="address" name="address" class="form-control" rows="5" placeholder="Address"&gt;&lt;?php echo $row['address']; ?&gt;&lt;/textarea&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
           
           &lt;!-- third section --&gt;
           
           &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label for="highest_qualification" type="text" id="highest_qualification"&gt;Highest Qualification&lt;/label&gt;
            &lt;input name="highest_qualification" class="form-control" type="text" maxlength="100" value="&lt;?php echo $row['highest_qualification'] ?&gt;"/&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
           
           &lt;!--another section --&gt;
           &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label for="university" type="text" id="university"&gt;University&lt;/label&gt;
            &lt;input name="university" class="form-control" type="text" maxlength="100" value="&lt;?php echo $row['university'] ?&gt;"/&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
           
           &lt;!--another section --&gt;
           &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label for="major" type="text" id="major"&gt;Major&lt;/label&gt;
            &lt;input name="major" class="form-control" type="text" maxlength="100" value="&lt;?php echo $row['major'] ?&gt;"/&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
          
           &lt;!-- another section--&gt;
                                      
           &lt;div class="row"&gt;
                                          &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="current_position" type="text" id="current_position"&gt;Current Position&lt;/label&gt;
                                                  &lt;input type="text" class="form-control" name="current_position" value="&lt;?php echo $row['current_position'] ?&gt;"/&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="position_appled" type="text" id="position_applied"&gt;Position Applied&lt;/label&gt;
                                                  &lt;input type="text" class="form-control" name="position_applied" value="&lt;?php echo $row['position_applied'] ?&gt;"&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
            &lt;/div&gt;
            
            
            &lt;!--another section --&gt;
            
           &lt;div class="row"&gt;
                                          &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="current_monthly_salary" type="text" id="current_monthly_salary"&gt;Current Monthly Salary&lt;/label&gt;
                                                  &lt;input type="text" class="form-control" name="current_position" value="&lt;?php echo $row['current_monthly_salary'] ?&gt;"&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          
            &lt;div class="col-md-6"&gt;
                                              &lt;div class="form-group"&gt;
                                                  &lt;label for="expected_monthly_salary" type="text" id="expected_monthly_salary"&gt;Expected Monthly Salary&lt;/label&gt;
                                                  &lt;input type="text" class="form-control" name="position_applied" value="&lt;?php echo $row['expected_monthly_salary'] ?&gt;"&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
            &lt;/div&gt;
            
           &lt;!--another section --&gt; 
          &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label for="prefered_working_location" type="text" id="prefered_working_location"&gt;Prefered Working Location&lt;/label&gt;
            &lt;input name="prefered_working_location" class="form-control" type="text" maxlength="100" value="&lt;?php echo $row['prefered_working_location'] ?&gt;" /&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
            
           &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label for="avaibility" type="text" id="avaibility"&gt;Avaibility&lt;/label&gt;
           &lt;select name = "avaibility" class="form-control " type="text" id="avaibility" value="&lt;?php echo $row['avaibility'] ?&gt;"&gt;
            &lt;option value=""&gt;-- select one --&lt;/option&gt;
            &lt;option value="Immediately"&gt;Immediately&lt;/option&gt;
            &lt;option value="One Month"&gt;One Month&lt;/option&gt;
            &lt;option value="Two Month"&gt;Two Month&lt;/option&gt;
            &lt;option value="Three Month"&gt;Three Month&lt;/option&gt;     
           &lt;/select&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
            &lt;/div&gt;
  
           
           &lt;div class="row"&gt;
           &lt;div class="col-md-12"&gt;
           &lt;div class="form-group"&gt;
           &lt;label for="language" type="text" id="language"&gt;Language Proficiency&lt;/label&gt;&lt;br /&gt;
                              
            &amp;nbsp&amp;nbsp&amp;nbsp&lt;p&gt;Proficiency level 0-poor; 10-excellent&lt;/p&gt;
  
  
           &lt;table border="2" bordercolor="gray" align="center"&gt;
  
           &lt;tr&gt; 
            &lt;td&gt;
             &lt;label for="malay" type="text" id="malay" placeholder="Malay" style="color:black; width:200px"&gt;&lt;b&gt;Malay&lt;/b&gt;&lt;/label&gt;&lt;br /&gt;
            &lt;/td&gt; 
  
            &lt;td&gt;
             &lt;input name="malay" type="text" class="form-control" maxlength="100" style="width: 200px" value="&lt;?php echo $row['malay'] ?&gt;"/&gt;
  
            &lt;/td&gt; 
           &lt;/tr&gt;  
  
           &lt;tr&gt; 
            &lt;td&gt;
             &lt;label for="english" type="text" id="english" placeholder="English" style="color:black; width:200px"&gt;&lt;b&gt;English&lt;/b&gt;&lt;/label&gt;&lt;br /&gt;
            &lt;/td&gt; 
  
            &lt;td&gt;
             &lt;input name="english" type="text" class="form-control" maxlength="100" style="width: 200px" value="&lt;?php echo $row['english'] ?&gt;"/&gt;
  
            &lt;/td&gt; 
           &lt;/tr&gt;  
  
           &lt;tr&gt; 
            &lt;td&gt;
             &lt;label for="mandarin" type="text" id="mandarin" placeholder="Mandarin" style="color:black; width:200px"&gt;&lt;b&gt;Mandarin&lt;/b&gt;&lt;/label&gt;&lt;br /&gt;
            &lt;/td&gt; 
  
            &lt;td&gt;
             &lt;input name="mandarin" type="text" class="form-control" maxlength="100" style="width: 200px" value="&lt;?php echo $row['mandarin'] ?&gt;"/&gt;
  
            &lt;/td&gt; 
           &lt;/tr&gt;
  
           &lt;tr&gt; 
            &lt;td&gt;
             &lt;label for="other" type="text" id="other" placeholder="Other" style="color:black; width:200px"&gt;&lt;b&gt;Others&lt;/b&gt;&lt;/label&gt;&lt;br /&gt;
            &lt;/td&gt; 
  
            &lt;td&gt;
             &lt;input name="other" type="text" class="form-control" maxlength="100" style="width: 200px" value="&lt;?php echo $row['other'] ?&gt;"/&gt;
  
            &lt;/td&gt; 
           &lt;/tr&gt;  
  
           &lt;/table&gt;
           
           &lt;/div&gt;
           &lt;/div&gt;
           &lt;/div&gt;
            
            
  
                                      &lt;div class="row"&gt;
                                          &lt;div class="col-md-12"&gt;
                                              &lt;div class="form-group"&gt;
                                         
                                              &lt;label for="aboutme" type="text" id="aboutme"&gt;&lt;b&gt;About Me&lt;/b&gt;&lt;/label&gt;&lt;br /&gt;
             &lt;p&gt;Summarize your employement history (Not more than 100 words)&lt;/p&gt;
             &lt;textarea class="form-control" rows="6" id="aboutme" name="aboutme" maxlength="400" style="width: 560px"value="&lt;?php echo $row['aboutme'] ?&gt;"&gt;&lt;/textarea&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
           
           
           &lt;div class="row"&gt;
                                      &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label style="color:black;"&gt;Latest passport photo&lt;/label&gt;
            &lt;input class="btn btn-danger" type="file" name="image" id="profile-img" /&gt;&lt;br&gt;
            &lt;img src="../uploads/candidate/&lt;?php echo $row['photo']; ?&gt;" id="profile-img-tag" width="200px" /&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
            
           &lt;div class="col-md-6"&gt;
                                        &lt;div class="form-group"&gt;
                                          &lt;label style="color:black;"&gt;File format PDF and doc only!&lt;/label&gt;
            &lt;input type="file" name="resume" class="btn btn-danger" /&gt;
                                          &lt;/div&gt;
                                          &lt;/div&gt;
           &lt;/div&gt;
          
                                      &lt;button type="submit" class="btn btn-info btn-fill pull-right"&gt;Update Profile&lt;/button&gt;
                                      &lt;div class="clearfix"&gt;&lt;/div&gt;
           
            &lt;?php
          
          }
         }
         ?&gt;
                                  &lt;/form&gt;
         
     &lt;?php if(isset($_SESSION['uploadError'])) { ?&gt;
              &lt;div class="row"&gt;
                &lt;div class="col-md-12 text-center"&gt;
                  &lt;?php echo $_SESSION['uploadError']; ?&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;?php } ?&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
       
       &lt;!--second part of picture and resume --&gt;
                      &lt;div class="col-md-4"&gt;
                          &lt;div class="card card-user"&gt;
                             
            &lt;div class="image"&gt;
                                  &lt;img src="https://ununsplash.imgix.net/photo-1431578500526-4d9613015464?fit=crop&amp;fm=jpg&amp;h=300&amp;q=75&amp;w=400" alt="..."/&gt;
                              &lt;/div&gt;
                              
         &lt;div class="content"&gt;
                                  &lt;div class="author"&gt;
                                       &lt;a href="#"&gt;
            
             &lt;img class="avatar border-gray" src="../uploads/candidate/&lt;?php echo $row['photo']; ?&gt;" alt="..."/&gt;           
                                        &lt;h4 class="title"&gt;&lt;?php echo $_SESSION['name']; ?&gt;&lt;br /&gt; &lt;/h4&gt;
                                      &lt;/a&gt;
      &lt;/div&gt;
      &lt;/div&gt;
                              &lt;hr&gt;
                              &lt;div class="text-center"&gt;
                                  &lt;button href="#" class="btn btn-simple"&gt;&lt;i class="fa fa-facebook-square"&gt;&lt;/i&gt;&lt;/button&gt;
                                  &lt;button href="#" class="btn btn-simple"&gt;&lt;i class="fa fa-twitter"&gt;&lt;/i&gt;&lt;/button&gt;
                                  &lt;button href="#" class="btn btn-simple"&gt;&lt;i class="fa fa-google-plus-square"&gt;&lt;/i&gt;&lt;/button&gt;
  
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and this is update-profile.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  //To Handle Session Variables on This Page
  session_start();
  
  if(empty($_SESSION['id_user'])) {
    header("Location: ../index.php");
    exit();
  }
  
  //Including Database Connection From db.php file to avoid rewriting in all files
  require_once("../db.php");
  
  //if user Actually clicked update profile button
  if(isset($_POST)) {
  
    //Escape Special Characters
   if(isset($_POST)) {
   $user_name = mysqli_real_escape_string($conn, $_POST['user_name']);
   $ic_no = mysqli_real_escape_string($conn, $_POST['ic_no']);
   $nationality = mysqli_real_escape_string($conn, $_POST['nationality']);
   $gender = mysqli_real_escape_string($conn, $_POST['gender']);
   $race = mysqli_real_escape_string($conn, $_POST['race']);
   $ic_no = mysqli_real_escape_string($conn, $_POST['ic_no']);
   $contactno = mysqli_real_escape_string($conn, $_POST['contactno']);
   $email = mysqli_real_escape_string($conn, $_POST['email']);
   $address = mysqli_real_escape_string($conn, $_POST['address']);
   $highest_qualification = mysqli_real_escape_string($conn, $_POST['highest_qualification']);
   $university = mysqli_real_escape_string($conn, $_POST['university']);
   $major = mysqli_real_escape_string($conn, $_POST['major']);
   $current_position = mysqli_real_escape_string($conn, $_POST['current_position']);
   $position_applied = mysqli_real_escape_string($conn, $_POST['position_applied']);
   $current_monthly_salary = mysqli_real_escape_string($conn, $_POST['current_monthly_salary']);
   $expected_monthly_salary = mysqli_real_escape_string($conn, $_POST['expected_monthly_salary']);
   $prefered_working_location = mysqli_real_escape_string($conn, $_POST['prefered_working_location']);
   $avaibility = mysqli_real_escape_string($conn, $_POST['avaibility']);
   $malay = mysqli_real_escape_string($conn, $_POST['malay']);
   $english = mysqli_real_escape_string($conn, $_POST['english']); 
   $mandarin = mysqli_real_escape_string($conn, $_POST['mandarin']);
   $other = mysqli_real_escape_string($conn, $_POST['other']);
   $aboutme = mysqli_real_escape_string($conn, $_POST['aboutme']);
  
   $uploadOk = true;
  
   if(isset($_FILES)) {
  
    $folder_dir = "../uploads/resume/";
  
    $base = basename($_FILES['resume']['name']); 
  
    $resumeFileType = pathinfo($base, PATHINFO_EXTENSION); 
  
    $file = uniqid() . "." . $resumeFileType;   
  
    $filename = $folder_dir .$file;  
  
    if(file_exists($_FILES['resume']['tmp_name'])) { 
     
     if($resumeFileType == "pdf")  {
  
      if($_FILES['resume']['size'] &lt; 500000) { // File size is less than 5MB
  
       move_uploaded_file($_FILES["resume"]["tmp_name"], $filename);
  
      } else {
       $_SESSION['uploadError'] = "Wrong Size. Max Size Allowed : 5MB";
       header("Location: edit-profile.php");
       exit();
      }
     } else {
      $_SESSION['uploadError'] = "Wrong Format. Only PDF Allowed";
      header("Location: edit-profile.php");
      exit();
     }
    }
   } else {
    $uploadOk = false;
   }
  
   
  
   //Update User Details Query
  
  $sql= "UPDATE users set user_name='$user_name', ic_no='$ic_no', gender='$gender', nationality='$nationality', race='$race', email='$email', contactno='$contactno', highest_qualification='$$highest_qualification',
   university='$university', major='$major', current_position='$current_position', position_applied='$position_applied', current_monthly_salary='$current_monthly_salary', 
   expected_monthly_salary='$expected_monthly_salary', prefered_working_location='$prefered_working_location', avaibility='$avaibility', malay='$malay', english='$english',
   mandarin='$mandarin', other='$other', photo='$file', resume='$file', aboutme='$aboutme'";
  
   if($uploadOk == true) {
    $sql .= ", resume='$file'";
   }
  
   $sql .= " WHERE id_user='$_SESSION[id_user]'";
  
   if($conn-&gt;query($sql) === TRUE) {
    $_SESSION['user_name'] = $user_name;
    //If data Updated successfully then redirect to dashboard
    header("Location: index.php");
    exit();
   } else {
    echo "Error ". $sql . "&lt;br&gt;" . $conn-&gt;error;
   }
   //Close database connection. Not compulsory but good practice.
   $conn-&gt;close();
  
  } else {
   //redirect them back to dashboard page if they didn't click update button
   header("Location: edit-profile.php");
   exit();
  
   
  }};</code></pre>
  </div>
  </div>
  </p>