I am having a problem with displaying an image from mysql with base64_decode.
my image viewer looks like this:
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/site/dbconnect.php'); $result=mysql_query("SELECT * FROM images WHERE p_id='".$_GET['p_id']."'"); $table_returns=mysql_fetch_array($result); $encoded=$table_returns['data']; $image_name=$table_returns['image_name']; $the_date=$table_returns['date']; mysql_close($connect); echo base64_decode($encoded); echo $image_name; echo $the_date; ?>
I don't know what I am doing wrong. When I pass an id through the url I always get this back:
IHDR``múào pHYsšœ MiCCPPhotoshop ICC profilexÚSwX“÷>ß÷eVBØð±—l"#¬ÈY¢’a„@Å…ˆ VœHUÄ‚Õ Hˆâ (¸gAŠˆZ‹U\8îÜ§µ}zïííû×û¼çœçüÎyÏ€&‘æ¢j9R…<:ØOHÄÉ½€Hà
This is the part of my upload script that codes it:
//record the image contents into a variable $contents1 = fread($fp1, filesize($filename1)); //close the file fclose($fp1); //encode the image into text $encoded = chunk_split(base64_encode($contents1));
edit: i should probably mention that $the_date and $image_name both work fine