Hello I'm trying to display images from my database using blob but the browser diplays them in a unusual way.
This is what I get!!!
<82<.231 1!!11111111111111111111111111111111111111111111111111������������� ������� ���}�!1AQa"q2���#B��R��$3br�
What is it that i'm doing wrong? I tried adding a header(contect-type:image.jpeg) but is not working for me :(
Here is the code:
<?php
//database info in misc.inc
include("misc.inc");
//Get item ID
$id = $_GET["itemID"];
$db = 0;
//Connect to database
$db = mysql_connect($db_host . ":" . $db_port, $db_user, $db_pwd);
if ($db == 0) {die("Cannot connect, Error <b>" . mysql_errno() . "</b>: " . mysql_error());};
mysql_query("USE " . $db_db);
if (mysql_errno() != 0) {die("Cannot USE database, Error <b>" . mysql_errno() . "</b>: " . mysql_error());};
//fetch data from database
$query1 = "SELECT * FROM images, items WHERE (images.itemID='$id' && items.itemID='$id')";
$result = mysql_query($query1);
while ($row = mysql_fetch_array ($result))
{
echo"<table>";
echo"<tr>";
echo"<td colspan='2'>
<h2 style='font-size: large;'> ".$row['itemName']."</h2></td>\n";
echo "</tr>";
echo "<tr>";
echo"<td><img border='0' align='right' src='../images/{$row['pix']} alt='item Image' style='margin-left: 5px;'></td>\n";
echo"<tr>";
echo"<td colspan='2'>
<div>
<b>Price: </b>£" .number_format ($row['price'],2). "<br />
<b>Posted On: </b>" .$row['submitDate']. "<br />\n
</div><br>
<b>Description: </b><p>" .$row['item_Description']. "<p><br />
<div ;='' style=clear: both;>
<h4 style='font-size: medium;'>Contact details:</h4>
<b>Name: </b>" .$row['contactName']. "<br />
<b>E-mail: </b>".$row['email']." <br /><br />
</div></td>\n";
echo"</tr>\n";
}
echo "</table><br/>";
?>
Thanks a lot