Re: PHP and Images stored in mysql

From: Date: Thu, 10 Jan 2002 19:43:28 +0000
Subject: Re: PHP and Images stored in mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80065@lists.php.net to get a copy of this message
How can I echo an image from other location than the mysql using this kind of script?? since I'm using php to output the image from database, there's a way to change it to a ftp link for example if image doesn't exists?? this is my script: <? $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); } } ?> and I call it from my page with <img src="lib_image.php?celebID='1'">. Thank's Rodrigo on 1/9/02 9:16 PM, Bogdan Stancescu at mgv@fx.ro wrote: > My way around this is using two fallback stages: for one you test > mysql_num_rows() after performing the query. If that's 0, use a default image > placed in the database beforehand. If that also returns a null > mysql_num_rows() > then echo an image (probably the same default) from a known location in the > filesystem. > > HTH > > Bogdan > > Rodrigo Peres wrote: > >> 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 ??? > --

« previous php.general (#80065) next »