PDA

View Full Version : PHP header already changed but i get garbage as jpg



imagined
April 2nd, 2004, 05:25 PM
I have 2 files:

include_display.php << contains the connection to the database, get the blobData and the blobType. Uses variable blobType to change the header.

$dbQuery = "SELECT blobType, blobData ";
$dbQuery .= "FROM testBlobs ";
$dbQuery .= "WHERE blobId = $blobId";

$result = mysql_query($dbQuery) or die("Couldn't get file list");

$data = @mysql_fetch_array($result);
if(!empty($data["blobData"]))
{

// Output the MIME header
header("Content-Type: $blobType");
}

else
{
echo "Record doesn't exist.";
}

and then I have display.php << its supposed to display the image
but instead of the image, i get bunches of letters, numbers, and symbols. of course, this means the header hasnt been changed.

echo $data["blobData"];

what am i doing wrong?

imagined
April 2nd, 2004, 05:42 PM
OK. Now, it already shows the picture, ONLY the picture. But all my text in the html file just went away.

how can I show both the body of my html file along with the picture inserted somewhere in the body?

imagined
April 2nd, 2004, 06:09 PM
uuummm. i take that back. still show garbage :S

Jubba
April 2nd, 2004, 08:42 PM
You can't do that. You have to create a separate file that creates the JPG. and then embed that into the HTML page with the <img> tag.

imagined
April 5th, 2004, 01:58 PM
You can't do that. You have to create a separate file that creates the JPG. and then embed that into the HTML page with the <img> tag.

How could I do that?

imagined
April 6th, 2004, 09:19 AM
Sooo, then a database would not be useful in this case, right?