Phpmyadmin blob php图像加密出来,想要将blob图像显示到网页上

时间:2014-07-24 23:39:48

标签: php html mysql css

问题在于:

代码是加密的,因此我无法在网页上显示blob图像,我希望blob显示为图像:

<?php
//connect to server
$connect = mysql_connect("localhost","root","");

//connect to database
mysql_select_db("website");

//query the database
$query = mysql_query("SELECT * FROM homepage");

//fetch results of database and convert to an array

while($rows = mysql_fetch_array($query)):
//

    echo "<div class = 'productBox1'>";
        echo "<img class = 'pImg1' src='{$rows['image']}' />";
        echo "<div class = 'pDesk1'>" . "<p>" . $rows['description'] . "</p>" . "</div>";
    echo "</div>";
//
endwhile;

?>

3 个答案:

答案 0 :(得分:0)

尝试将此插入您的PHP代码

$rows['image'] = base64_decode($rows['image']);

编辑:确保使用

将图像放入数据库
$image = base64_encode($image);

答案 1 :(得分:0)

使用此循环编辑。

while($rows = mysql_fetch_array($query))
{
$rows['image'] = base64_decode($rows['image']);
$image = $rows['image'];
$desc = $rows['description'];
?>
echo "<div class = 'productBox1'>";
    echo "<img class = 'pImg1' src=<?php echo $image;?> />";
    echo "<div class = 'pDesk1'>" . "<p>" . $desc . "</p>" . "</div>";
echo "</div>";
<?php
}
?>

答案 2 :(得分:-1)

将数组更改为assoc并查看是否有帮助(: 所以你的while循环看起来像这样 while($rows = mysql_fetch_assoc($query)):