Hello, I have been trying for a long time to get this to work I searched everywhere and they all end up with the same answer which does Not work for me how ever I might be doing something wrong please take a look at my code and tell me how to fix it, What I am trying to achieve is pretty simple, I save an image to a database using Blob Type, All works fine but i am having a trouble Displaying the image back. Here is the code from the get_image.php : <?php include('includes/mysql_connect.php'); $id = (int) $_GET['id']; $q = "SELECT `image` FROM `testi` WHERE id='$id'"; $r = mysqli_query($db_con_misc, $q); $image = mysqli_fetch_assoc($r); header("Content-type : image/JPEG "); echo $image['image']; ?> Code (markup): Here is the code from edit_testimonials.php : if(isset($_POST['submit'])){ $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); $q = "INSERT INTO `testi` (`message`,`image`,`active`,`by`) VALUES ( '{$_POST['message']}', '$image', '{$_POST['active']}', '{$_POST['nickname']}')"; $r = mysqli_query($db_con_misc, $q); if($r){ $last_id = mysqli_insert_id($db_con_misc); echo "<img src=\"get_image.php?id=1\" /><p />"; echo "Testimonial has been added <a href=\"home.php\">- Go back</a><p />"; exit(); }else{ die("Database Error : " . mysqli_error($db_con_misc)); } } ?> <body> // html form bellow <fieldset><legend>ADD Testimonial</legend> <form action="edit_testimonials.php" method="post" enctype="multipart/form-data"> Message :- <textarea name="message"></textarea><br /><br /> Nickname :- <input type="text" name="nickname" value="" /><br /><br /> Image :- <input type="file" name="image" value="" /> (64 KiB Max) <br /><br /> Status :- <input type="text" name="active" value="" /> ( yes or no )<br /><br /> <input type="submit" name="submit" value="ADD" /><br /><br /> </form> </fieldset> Code (markup): It is pretty simlple actually I add an image to the database and then it displays it by sending the Id of the image to another php page (get_image.php) and it returns with the image... Please help me all i get is a broken image and when i try to do this directly on the get_image.php?id=XXX it returns with the Binary Rubbish That was originally inserted into MySQL. Thanks in advance, Kind Regards, Issa Shamoun.
http://www.techcubetalk.com/2009/01/tutorial-on-how-to-store-images-in-mysql-blob-field/ check this out and see if it is different