Jump to content

image from database displays like ƒ„…†‡ˆ‰Š’“”•–


stimpson

Recommended Posts

allright, after a few days i give up. When trying to display an image from database i get a page full of ƒ„…†‡ˆ‰Š’“”•–crap.  I´ve tried several pre-written scripts as well the base-code but still the same.

$fileType = @mysql_result($result, 0, "type");
$fileContent = @mysql_result($result, 0, "data");
header("Content-type: $fileType");
echo $fileContent;

data-field is blob.

php -> 4.3.9
mysql -> 4.1
my coffee -> strong.

i found 1 answer for this question on a forum and the answer was that the guy realy should try another code.. could someone pleeeaaaase give me a usefull explanation¿ cause it really doesnt look like something heavy, but just enoying.

thanx!
Link to comment
Share on other sites

ah, sorry, i knew that i forgot something, but the data is entered with:

$dbQuery = "INSERT INTO bltira VALUES ";
$dbQuery .= "(0, '$strDesc', '$fileContent', '$fileUpload_type')";

the rest of the script you can find here:
http://www.devarticles.com/c/a/MySQL/Blobbing-Data-With-PHP-and-MySQL/

seems to be an goldy-oldy, but the base-scripting (storing/retrieving) seems to be pritty recent.
please tell me if i´m wrong, the main point for me is that this script is gonna work so i can go one with recent phpmysql. Thanx for all support  :)
Link to comment
Share on other sites

i try with:
i.e.5
firefox 1.5

GD Version bundled (2.0.28 compatible)
and jpeg/gif/png etc enabled

also get this message sometimes in the beginning of the binary:
CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality

i saw an working example on the net at this link
http://www.wellho.net/demo/pic_up.php4

oh, by the way please tell me if i´m not allowed to paste urls or whatever
thanx
Link to comment
Share on other sites

hmmmm..  tryd the following headers:

header("Content-type: $fileType");
header("Content-type:'".$fileType);
header("Content-type: file/jpeg");

so the binary data string seems te be allright, it´s just the conversion that goes wrong somewhere¿

then, any idea where and what i could try to change¿
Link to comment
Share on other sites

[color=red]just found out! [/color]
when i´m placing this code.. 

header("Content-type: $type");

..then the coding [color=red]ís[/color] the same as in wordpad, only the first 2 rules i´m not sure because notepad gives here squares instead of binary, but both dataoutput and notepad start with.. 

ÿØÿà JFIF [color=red]instead of[/color] CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality

..followed by the binary-spaghetti.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.