好的,我试着从我的数据库中提取图像,这里是代码:
HTML:
><img src="imagePrevie.php?ID=<?php echo $lastImage2['id'] ; ?>"><?php
$ lastImage2返回真值
和imagePrevie.php:
$id=addslashes($_GET['ID']);
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=lacajota', 'root', '', $pdo_options);
$lastImagePrev = $bdd->query("SELECT * FROM imagenes WHERE id=$id");
$lastImagePrev2 = $lastImagePrev->fetch();
}
catch(Exception $e)
{
die('Error:' . $e->getMessage());
}
header("Content-type: image/jpeg");
echo $lastImagePrev2['image'];
我没有错误,图片就没出现了!
谢谢