Display a database image from MSSQL database

From: Date: Wed, 18 May 2005 17:28:40 +0000
Subject: Display a database image from MSSQL database
Groups: php.general 
Request: Send a blank email to php-general+get-215505@lists.php.net to get a copy of this message
Hi... I need to display some images that exists inside one MSSQL server in a BLOB datatype field, but my code don't work... My code: <? $arg = $_GET["codPessoa"]; mssql_connect("server", "web", "web"); $sql = "SELECT Foto FROM Foto WHERE CodPessoa=$arg"; $result = mssql_query($sql); $data = mssql_result($result, 0, "Foto"); $data = stripslashes($data); header("Content-type: image/gif"); echo $data; exit; ?> And I access this page sending in the URL the text: .../showimage.php?codPessoa=xxx. I receive a strange code like Fh54757eFg554257eFrgtth547d54e7t8h54j87j85fd54ss7f...... Accessing this page by IE nothing happens but when a I try to access in Mozilla Firefox I got an error saying that the image cointain errors and cannot be displayed... If i try to show inside an img TAG in other page like <img src="patch/to/page" /> the code display a X error img, like if the image don't exist, but the code keep returning the strange code, so I believe that this is the image in a "string format" and something makes with the conversion for a real image format don't work very well. Sorry my bad english...

« previous php.general (#215505) next »