PHP and Images stored in mysql
| From: | Rodrigo Peres | Date: | Wed, 09 Jan 2002 22:13:06 +0000 |
| Subject: | PHP and Images stored in mysql | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79965@lists.php.net to get a copy of this message | ||
Hi list,
I have some images stored in a blob in mysql. I've made this code to output
them to html, but the problem is if there's no image at a given id the page
tooks a long time to load and display the "broken image", there's a way to
avoid this, I mean, there's a way to print a message or another image if
there's none in mysql ???
<?
$sql = "SELECT Imagem_data,Imagem_type FROM imagens WHERE
CelebID='$celebID'";
$query = new Query($conexao);
$query->executa($sql);
$resultado = $query->dados();
mysql_close();
$imagem_banco = $resultado['Imagem_data'];
$type = $resultado['Imagem_type'];
if($imagem_banco != "") {
HEADER("Content-type: $type");
echo($imagem_banco);
}
}
?>
Thank's in advance
Rodrigo
--