所以我在从我的数据库显示BLOB时遇到一个小问题,我尝试了所有但没有结果,只是一些丑陋的角色,我知道这是一些愚蠢但它让我发疯,这是代码:
<?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>';
}
}
} ?&GT;
在我的数据库图片设置为'blob',其余很简单,我的页面上也有打印(“$ output”),但这与此无关,我希望有人可以免费帮助:D
答案 0 :(得分:0)
尝试这样。
用于插入DB
$image = addslashes(file_get_contents($_FILES['images']['tmp_name']));
用于从Blob访问图像
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';