Jump to content

Problem with displaying a Long Blob


mark110384

Recommended Posts

The problem is that I cannot display a long blob for some reason, it just display anything and when you select view image the url is displayed like so

 

http://localhost/example/cart/image.php?item_id=%20F0800

 

I send the itemId that will be referenced to the image through the URL using this code.

 

echo "<img src='image.php?item_id= $itemid'>";

 

I then get the ID and check the database, but it just doesn't display the image! Can anyone please help. Any suggestions will be welcomed and appreciated.

 

<?

header('Content-Type: image/jpeg');

 

 

$dbhost = "*****";

$dbuser = "****";

$dbname = "****";

 

$itemid = $_GET["item_id"];

 

 

 

$dbconnect = mysql_connect("$dbhost", "$dbuser")or die("Could not connect to database");

 

mysql_select_db("$dbname") or die("Could not select db");

 

$sql = "SELECT image FROM items WHERE itemId = '$itemid'";

 

$result = mysql_query($sql, $dbconnect);

 

$row = mysql_fetch_array($result);

 

$sJpg = $row["image"];

 

echo $sJpg;

 

?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/109852-problem-with-displaying-a-long-blob/
Share on other sites

so you are storing the picture inside, right?

 

you may alternatively store the picture as a file and store in the database the path and the filename instead. that way, the database will not easily get bloated. and the query will run faster.

 

just a suggestion though that you might want to try. :)

 

Jay,

After a little searching, I found this page: http://www.weberdev.com/get_example-167.html

 

Seems to do what you want to do, just have to work around their code.  However, I don't know why you'd want to load files from a database rather than the files themselves from their directory.

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.