Jump to content

image problem


bhavin_85

Recommended Posts

hey guys

 

ive got an image stored in my database that im trying to retrieve.

ive written this code but its just bring up line and lines of rubbish text  ???

<?
session_start();
if ( empty($_SESSION['username'])){
header("location:default.php");
exit;
}

$id=$_SESSION['cust_id'];

include ('config.php');

$sql = "SELECT invoice_id FROM invoices WHERE cust_id='$id'";
$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
    $invoice_id = $row['invoice_id'];

$sql1 = "SELECT i.item_item_id, COUNT(*) as total
FROM invoices v INNER JOIN invoice_items i ON v.invoice_id = i.invoices_invoice_id
WHERE v.cust_id='$id'
GROUP BY i.item_item_id
ORDER BY total DESC
LIMIT 1";
$query1 = mysql_query ($sql);
$most_frequent_id = mysql_result ($query1, 0); 
}
$sql2 = "SELECT image FROM images where item_item_id = $most_frequent_id";
$query2 = mysql_query($sql2) or die(mysql_error());
$image = mysql_result($query2,0,"image");


?>
<html>
<head>
<title>P.B.L. Jewellers Ltd</title>
</head>
<body bgcolor="#030102" text="#666666">
<div>
<table width="670" height="546" border="0" align="center" bordercolor="#000000">
  <tr>
      <td colspan="2" align="right" height="10">
        <? 
  echo "You are logged in as " . $_SESSION['uname'] . ""?>
        <a href="default.php">Logout</a> </td>
  </tr>
  <tr> 
    <td colspan="3" valign="top" width="670" height="158"> <img src="images/banner2.png" width="670" height="158" align="top"> 
    </td>
  </tr>
  <tr>
  <td colspan="3" align="center" height="20"><? readfile("menu_promo.inc"); ?>
  </td>
  </tr>
<tr>  
     <td>
    <? 
header("Content-type: image/png");
echo $image; ?>
      </td> 
</tr>
    <tr> 
      <td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</body>
</html>

any1 know where im going wrong ?

 

Link to comment
https://forums.phpfreaks.com/topic/43257-image-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.