1

so i'm having a small problem in displaying a BLOB from my database , I tried everything but with no results , just some ugly characters , I know it's something silly but it drives me crazy , here is the code:

<?php
conect..
//collect
 if(isset($_POST['search'])) {
$searchq = $_POST['search'];

$query = mysql_query("SELECT * FROM thinking_search.search WHERE title LIKE '%$searchq%' OR keywords LIKE '%$searchq%'");
$count = mysql_num_rows($query);
if($count == 0) {
    $output = 'There are no articles on this topic...';
}else{
      while($row = mysql_fetch_array($query)) {
          $title = $row['title'];
          $keywords = $row['keywords'];
          $id = $row['id'];
          $link = $row['link'];
          $picture = $row['picture'];
          $description = $row['description'];

          $output .='<div id="u"><a href="'.$link.'"><img src="data:image/jpeg;base64,'.base64_encode( $picture ).'"/> <div id="title">'.$title.' </div> <div id="key">'.$keywords.'</div><div id="description">'.$description.'</div></a></div>';

    }
}

} ?>

In my database picture is set to 'blob' , the rest is simple , I also have a print("$output") on my page but that has nothing to do with this , I hope there could be someone free to help :D

1 Answers1

0

Try Like this.

For Inserting into DB

$image = addslashes(file_get_contents($_FILES['images']['tmp_name']));

For Accessing image From Blob

    echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';
AnkiiG
  • 3,468
  • 1
  • 17
  • 28