Image does not show up from mysql database

2014-02-20T23:04:46

I'm trying to show an image from my database yet it wont show. I researched and tried different codes that I can understand but it is still no use. Here is my show image php code

<?php

$host="localhost";
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_tocode="db_tocode"; // Database name 

mysql_connect($host, $username, $password) or die("Can not connect to database:     ".mysql_error());

mysql_select_db($database) or die("Can not select the database: ".mysql_error());

$id = $_GET['id'];

$sql = "SELECT * FROM image WHERE id = '$id';";

 $result = mysql_query($sql) or die(mysql_error());  
$row = mysql_fetch_array($result);

header("Content-type: image/jpeg");
echo $row['image'];


?>

and here is the link to show the image to the site.

     <img src="showimage.php?id=<?php echo $id;?">">
     <div class="text-style"></div>

thanks in advance!

Copyright License:
Author:「bjmonts」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/21911631/image-does-not-show-up-from-mysql-database

About “Image does not show up from mysql database” questions

I'm trying to show an image from my database yet it wont show. I researched and tried different codes that I can understand but it is still no use. Here is my show image php code &lt;?php $host="
guys. I tried to load image stored in mysql blob field with php, but the image does not show correctly. In firebug, I got these infos: get-image.php Dimensions0 × 0File size5.35KBMIME typeimage/jpeg
I have the following model. I successfully insert the data to mysql database, but I cannot show the image in the index page. How can I show LargeBinary object from mysql as an image in my template?
I am creating a data saving software using C++ Builder. I have placed a TDBGrid on my Form, where I show information from my MySQL database. There is an image column in my grid where I want to show
image is not displaying from the database it show just showing broken image &lt;?php $con = mysql_connect('localhost', 'root', ''); //Update hostname mysql_select_db("postad", $con); //Update da
Okay i have a site wich makes signatures. But because some header problems i had to put it in another file and use echo. this is the code: &lt;h1&gt;Create your European Trucking signatures&lt;/h1...
I'm able to send strings from my app to my remote database! I'm able to download images from database to my app and show they properly! But if I want send an image from the app to my database? I th...
On our website, we switched to a new CDN to host our images and ever since then images does not show up in sharer. There are 2 different behaviors we are experiencing: Image does not show up in sh...
I am noticing a very strange issue with my MySQL 5.6.23. Why would a MySQL database show up in SHOW DATABASES but not in the information_schema table? I was trying to find out the sizes of all my
I was trying to call some image in the div tag. All the other variables are showed up, but only the image won't show up. Can anyone point out the mistakes? Here's the code. &lt;div class="row"&gt;...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.