Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

DISPLAYING A BLOB IMAGE FROM MYSQL

images php coding issues or problems here.

Moderators: macek, egami, gesf

DISPLAYING A BLOB IMAGE FROM MYSQL

Postby imadraf » Sun Jun 26, 2011 7:50 am

i wan't something like that:
<img src="show-image.php?id=<?php $_GET["id"]; ?>" title="Mon image"/>


get the page id and send it,


this work:
<img src="show-image.php?id=1" title="Mon image"/>



the code of show-image.php:
<?php
if ( isset($_GET['id']) )
{
$id = intval ($_GET['id']);
include ("connexion.php");
$req = "SELECT img_id, img_type, img_blob ".
"FROM image WHERE img_id = ".$id;
$ret = mysql_query ($req) or die (mysql_error ());
$col = mysql_fetch_row ($ret);
if ( !$col[0] )
{
echo "Id d'image inconnu";
}
else
{
header ("Content-type: ".$col[1]);
echo $col[2];
}
}
else
{
echo "Mauvais id d'image";
}
?>


if i use directly the show-image.php code there is another problem because of the header, i red on the web that there is a problem whith the header in a HTML/PHP page.
imadraf
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Jun 26, 2011 7:45 am

Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.