我无法从我的数据库检索图像 [英] I can't retrieve Image from my database

查看:123
本文介绍了我无法从我的数据库检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,包含电影名称,他们的描述和他们的封面图片。封面图片字段类型为blob,问题是我无法从数据库检索它。我想要在他们的封面图片旁边显示电影名字...如何做到..这是我的代码..

I have a database containing movies Name, their description and their cover picture. The cover picture field type is as blob and the problem is that I can't retrieve it from the database. I want to display the movie name along their cover picture beside them... How to do it.. Here is my code..

<?php

include ("php/connection.php");
$ID = $_GET['id'];
$listmovies = "SELECT * FROM movies where Genres LIKE '%$ID%'";
$result = mysql_query($listmovies);
while ( $row = mysql_fetch_assoc($result) ) {
    ?>
<table border="1" width="100%">
    <tr>
        <td rowspan="2" width="90" height="120">
<?php

    // set the header for the image
    header("Content-type: image/jpeg");
    echo $row['Image'];

    ?> </td>
        <td width="200" height="10">
<?php

    echo $row['Title'];
    ?></td>
    </tr>
    <tr>
        <td width="200" height="110"><a
            href="php/moredetails.php?id=<?php echo $row['ID']; ?>">More Detail</a></td>
    </tr>
<?php } ?> </table>

我只想在电影标题旁边显示The Imgaes?

I just want to display The Imgaes beside the title of the movie?

推荐答案

是的,它不会显示,因为上面的任何输出总是会产生错误 ... you需要有不同的页面才能输出您的图片或包含 base64 图片

Yes it won't display because any output above header would always generate error ... you need to have a different page to output your image or include it has base64 image

删除

header("Content-type: image/jpeg");
echo $row['Image'];

并添加:

printf("<img src=\"data:image/jpeg;base64,%s\" />",base64_encode($row['Image']));  
                               ^--- Note this is only for jpeg images

这篇关于我无法从我的数据库检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆