我试图显示我存储在表格中的图像“图像”。 [英] I am trying to display the images that I have stored in the table "images"
问题描述
以下是home.php页面,它应该显示图像以及数据库中的imageID。实际图像位于名为user_images的文件夹中,只有名称和文件路径存储在数据库中。
当我尝试显示它们时,imageID是检索但是immage不是,只有破碎的图像图标出现在屏幕上
prepare(SELECT * FROM images ORDER BY imageID
DESC);
$ stmt->执行();
}
catch(PDOException $ e)
{
$ e-> getMessage() ;
}
?>
Below is the home.php page that is supposed to display the images along with the imageID that are in the database. The actual images are in a folder called "user_images" and only the name and file path is stored in the database.
When I try to display them, the imageID is retrieved but the immage is not ,only broken image icons appear on the screen
prepare("SELECT * FROM images ORDER BY imageID
DESC");
$stmt->execute();
}
catch(PDOException $e)
{
$e->getMessage();
}
?>
rowCount()> 0)
{
while($ row = $ stmt-> fetch(PDO :: FETCH_ASSOC))
{
extract($ row);
?>
rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
我尝试了什么:
我试图添加标题(Content-type:image / jpg);到代码,但只是在页面的左上角显示一个小方块
我做错了什么?
What I have tried:
I have tried to add header("Content-type: image/jpg"); to the code but that just displays a small square at the top left hand side of the page
What am I doing wrong?
推荐答案
stmt-> execute();
}
catch(PDOException
stmt->execute();
}
catch(PDOException
e)
{
e)
{
e-> getMessage();
}
?>
e->getMessage();
}
?>
rowCount()> 0)
{
while(
rowCount() > 0)
{
while(
这篇关于我试图显示我存储在表格中的图像“图像”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!