0
显示多个图像BLOB我应该表现出从MySQL数据库中的一些BLOB的图像,此PHP代码:问题从MySQL
<?php
while ($articulo = mysql_fetch_array($resultados))
{
?>
<div class="categoria">
<a href="catalogo.php?categoria_serial=<?php echo $articulo['categoria_serial'];?>">
<img src="imagenCategoria.php?categoria_serial=<?php echo $articulo['categoria_serial'];?>&ancho=280" alt="">
</a>
<div class="descripcion">
<p><?php echo $articulo['categoria_nombre'];?></p>
</div>
</div>
<?php
}
?>
的问题是,不是每个图像显示在页面上。一些图像随机无法加载。如果我刷新页面,会出现一些丢失的图像,但一些正确的图像消失。
这里的每一个图像的代码:
<?php
include 'controller/_init.php';
$db = conectar();
$desired_width = $_GET["ancho"];;
$categoria_serial = $_GET["categoria_serial"];
$resultados = mysql_query("SELECT categoria_imagen FROM categoria WHERE categoria_serial = $categoria_serial") or die("Error");
$articulo=mysql_fetch_array($resultados);
$im = imagecreatefromstring($articulo['categoria_imagen']);
$x = imagesx($im);
$y = imagesy($im);
$desired_height = $desired_width*$y/$x;
$new = imagecreatetruecolor($desired_width, $desired_height);
imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width,$desired_height, $x, $y);
imagedestroy($im);
header('Content-type: image/jpeg');
imagejpeg($new, null, 85);
exit;
?>
任何线索?非常感谢你。
没错。保存斑点图像是一个非常糟糕的做法,必须避免。 – 2015-05-13 11:17:38