i need to show the image displayed in database but it shows default image

  <?php
      $link = new PDO("mysql:host=localhost;dbname=campusdrive", "root", "");
      $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $Sql = "SELECT Image FROM student_form WHERE Sessionid = :Sessionid";
      $stmt = $link->prepare($Sql);
      $stmt->bindParam(":Sessionid", $sessionid, PDO::PARAM_STR);
      $sessionid = session_id();
      $stmt->execute();
      $count = $stmt->fetchAll();
      if($users = $stmt->fetchColumn()){         
      echo '<img src="data:image; base64,'.base64_encode($count['Image']).'" style="margin-top: 100px;width: 100px; height: 100px; border-radius: 50px;">';
      } else {
      echo '<i class="fa fa-user-circle" style="font-size: 50px;"></i>';
      }
  ?>

Recommended Answers

All 2 Replies

rproffitt,

I think, if I'm reading this code right, line 10 is meant to have a single equals. As long as $users does not evaluate to something falsey, such as 0, FALSE, or NULL, then echo line 11. Otherwise, echo line 13.

The $users variable is not defined anywhere else in the code, and therefore would not make sense if it were a double equals.

What that means is that either there's something wrong with the SQL query, or it's not fetching the data it needs to be fetching, or it's not being properly retrieved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.