Re: get image from blob in mysql
| From: | Mike Frazer | Date: | Sat, 26 Jan 2002 16:49:27 +0000 |
| Subject: | Re: get image from blob in mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82210@lists.php.net to get a copy of this message | ||
The code below doesn't show the test you mentioned. By all means testing if
a variable = "" should work, but you may want to try something like
if (!$resultado['Imagem_data']) {
...
}
Sometimes testing a value against "" can cause problems because of
non-appearing whitespace that may exist in the variable. SOMETIMES, not all
the time, and I really couldn't tell you EXACTLY how PHP reacts to some of
these conditions, because I believe it to be system-dependent if memory
serves me (kind of like the differences between "\n" on Unix/Linux and
Windows). Just play around with things, but I'd like to see the code you
are using for this condition.
Mike Frazer
"Rodrigo Peres" <rperes@mac.com> wrote in message
news:B8783A47.86EB%rperes@mac.com...
> List,
>
> I'm using the following code to retrieve image from Mysql. My problem is
how
> can I output another image if the given ID doesn't have an image on it???
I
> had already inserted a blank gif in the database in order to use it, but
> I've tried to check if ($resultado['Imagem_data'] == "") or null and
> outputs the blank gif, but didn't work.
>
>
> $conexao = new conexao();
> $query = new Query($conexao);
> $sql = "SELECT Imagem_data,Imagem_type FROM imagens WHERE
> CelebID='$celebID'";
> $query->executa($sql);
> $resultado = $query->dados();
> $imagem_banco = $resultado['Imagem_data'];
> $type = $resultado['Imagem_type'];
> if($imagem_banco != "") {
> HEADER("Content-type: $type");
> echo($imagem_banco);
> }
>
> Thank's
>
> Rodrigo
> --
>
>