Here's the thing.
I've entered images as binary data into my database, using chunk_split() and base64_encode(), then I pull the out of the database using a script and output it to the browser. Now what I can't figure out, is for some reason, this was working perfectly for a few days, now suddenly it doesn't. I get several different scenarios.
- The script dies and says the image has errors
- The pure code of the image shows (in binary still)
- The page shows a complete blank, even in the source
- The page shows blank with just the page's URL, and in the source shows the binary image <- Most common one lately
- Or the page shows up in Dreamweaver (sends directly to HTML editor as if I downloaded the file) - in this case may have any combination of the above errors
Here is the latest model of the script.
<?php
require('config.php');
$image = (int)trim($_GET['img']);
$mysql->query("SELECT `image`, `image_type` FROM `user_images` WHERE `image_id`='$image' LIMIT 1");
$row = $mysql->fetch_array();
header("Content-type: {$row['image_type']}");
print $row['image'];
?>
I've went back and reviewed several tutorials dealing with this, even just simple outputing images, and I've delt with things like this before (except for pulling it out of a database). I can't figure it out. :S
Here's a link to the script in action, just so you can maybe see what it's doing.
Edit!
I fixed it! Lol.
Turns out I had to instigate an new instance of the MySQL class, seperate from the config file. I suspect having ob_start() and alot of session handling in the config file may be what caused some problems.
Edited by Demonslay, 12 November 2006 - 10:31 PM.
