mark110384 Posted June 12, 2008 Share Posted June 12, 2008 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 More sharing options...
bluejay002 Posted June 12, 2008 Share Posted June 12, 2008 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, Link to comment https://forums.phpfreaks.com/topic/109852-problem-with-displaying-a-long-blob/#findComment-563714 Share on other sites More sharing options...
xtopolis Posted June 12, 2008 Share Posted June 12, 2008 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. Link to comment https://forums.phpfreaks.com/topic/109852-problem-with-displaying-a-long-blob/#findComment-563717 Share on other sites More sharing options...
GingerRobot Posted June 12, 2008 Share Posted June 12, 2008 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. Definitely. Link to comment https://forums.phpfreaks.com/topic/109852-problem-with-displaying-a-long-blob/#findComment-563725 Share on other sites More sharing options...
mark110384 Posted June 16, 2008 Author Share Posted June 16, 2008 Cheers fellas, I've decided to store the file path in the database and reference it in the coding, Thanks for the input. Link to comment https://forums.phpfreaks.com/topic/109852-problem-with-displaying-a-long-blob/#findComment-566358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.