awebbdesign Posted October 3, 2009 Share Posted October 3, 2009 Hi All, I have done some script inserting a jpeg into a longblob, I know this works because I can see the image in the blob field using 'Navicat' however when trying to get the image out in PHP all I get is garbage. INDEX.PHP print "<img src='pages/portfolio/blob.php?id=$portD->id' alt='IMG' width='200' height='100' />"; BLOB.PHP include('../../connect.php'); $id = 140; $portS = "SELECT ablob FROM $table WHERE iid = '8' AND id = '$id'"; $portQ = mysql_query($portS); $portD = mysql_fetch_object($portQ); header("Content-type: image/jpeg"); print $portD->ablob; HELP!! I have googled everywhere, but it hust wont work, any pointers would be great. Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/ Share on other sites More sharing options...
MadTechie Posted October 3, 2009 Share Posted October 3, 2009 screen shot of start of the "garbage" maybe useful! Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/#findComment-929626 Share on other sites More sharing options...
awebbdesign Posted October 3, 2009 Author Share Posted October 3, 2009 Example below[clip]: ÿØÿà�JFIF��H�H��ÿÛ�C� !"$"$ÿÛ�CÿÀ��p�Ñ"�ÿÄ����������� ÿÄ�µ���}�!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ�������� ÿÄ�µ��w�!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ���?�ú‚¹‹+Õ<áy5ë =Zc›¤kÏ Æœ�ÃåmÜž•ÖÊéM$Œb{Ö¼w⎴/ü ñ…æŠ× ¢yÓDSsnR úŠøªQ¼–šî“H·Æé?™Úü)ñ^©ãO¦¿¡Ç£Ársj‹yç™Xü«·‘Ò°¼ñfËÄßuŸÅ§ˆ?³ÄžMßÚ7} ÆÁXmÚ6õ=ÏJ©ðç[Ã_³VŸ®È@šSʹîÁ›hüNxƒoî<'ãok×:&©¦—”Ũ^]ŵ.üé—SÜß"º#IIËOCÑ¥ƒ§RU4Úê>¨úƒâ¯Œïüi¤ÿ�eè ¬ÞjwÂÎe¹òNâ¬ÙÎÖþïµp!øÝâíÄ6>Õ>µ;ð¦ÚÝ5¥‘Ÿsv3ŽAë^©ã‹OÐå×uÈÌ:H7qK"183ÑŽvŒz׋|´m_Õ>5xÖH÷˜ôá3b8;w‚z�>QîXÔAÇ•¹GEù˜á¡Mʤoo[¶öJÇâïˆ^"ÓÕœgeÌã®ßðMcNŠ¢ç(kk-îÝ®Þû#Ñ~!뺆ü){éºBjÒY¡šXçÈýÒ‚YƒmlLs\§Ã"ñ‡/üQiàèañaj€ý¬©"@[Ë1ŒƒŸlWAñ~ø©A¦\ ÿ�¿M\gìÆøø`Ÿí]ÿ�Šrƒ§ÍÖç=*Pt\ÜnÔ’ë±›ðïãÕÇŒõ[½ÛÂ1ÛêKjóYÀú—ËrêFcÜcxÉÏ=+½øGãSÆþ:åï‡ÓG¶•ÊÚyç™B³+“ò®Ü2‘ï_/k7žÒ<ñ#N‹fwE6Þ7I®yÿ�y _¢×Ñ¿³ŒÁþhŸòÑ®Jƒïs)kF‡4Q×ÂR…/iN:7mÞ^ÿ�‘sâÄ3áïé^Ñô†ÖuíL†ÜÎ!gæw àpÝðš§añÄÑø÷LðŸˆüºdš‚HñÝŨyаEÉÛòŸPpGkœøåà+ßxªËVð~½ŸŠô›Uv·3yr‹6Ç>ï;Ç<çƒðÓâ'ì~&iþ ø“¦E%ì¹wRB‚h˜ƒ†¿++m##ó§EÂëþ •<59Ñæ‚M¤î›iú®–:Ý+âLj.>(7o¼oeuó&˜êÁ”C€ÛÔycwÊsŒúú¯¦ümŸTðˆüA¦xb)Žƒu²xQ ¾q(>_\ŒmÇã\§í1q7ƒ~(øsÇ6ˆOi5¬¸îUHçð“ÿ�¯0Ðì5 ^¸ðùÿ� M¾˜$>›Ú)[òÌ‹ZF”%+]NšX*5))¨¥tžï£×©ôÖ»ã¿éSÆw ‡ÎP&¸±þÓ�Åoòù<Œ®8Ï^* üCñ&¹ð¾ëÆÐx:(-µ¡Õg‰ Þû¼¿”§8/ŽŠ«ðsÄŠ {€aÅsß¿äÚm?ìuüä¬R‹íÔãŒ)J—?*¿5ºí½·2< ñêoEªÁaáãÕ,í~Õohú—(ó�sÚ@9>ÕÔé>?ñ£ð®oÇàØUÂ5Ä6_Úƒ2Û¨ËI¿ËàðØ\sÏ5ó¯‰-.|wà_éñbßRÑ¡ Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/#findComment-929630 Share on other sites More sharing options...
MadTechie Posted October 3, 2009 Share Posted October 3, 2009 Well that's a valid (start of) JPEG, and this appears when you load up BLOB.PHP it would seam like the header isn't being called header('Content-Type: image/jpeg'); Is that the full code ? I don't get how your getting the raw data, with a header used.. you wouldn't get an image but you wouldn't get the data.. theirs some detail missing! Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/#findComment-929677 Share on other sites More sharing options...
awebbdesign Posted October 3, 2009 Author Share Posted October 3, 2009 I have had some luck recreating the script in a seperate folder... <?php include('connect.php'); $bid = $_GET['bid']; $imageS = "SELECT * FROM phpblob WHERE id = '$bid'"; $imageQ = mysql_query($imageS); $imageD = mysql_fetch_object($imageQ); header("Content-type: image/jpeg"); print "$imageD->bbblob"; ?> The weird thing is, this now works, but not on the site that I am trying to get to work, it doesn't. I may have to take a break and look at this another time. Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/#findComment-929684 Share on other sites More sharing options...
MadTechie Posted October 3, 2009 Share Posted October 3, 2009 okay, different test try this.. <?php error_reporting(E_ALL); include('connect.php'); $bid = $_GET['bid']; $imageS = "SELECT * FROM phpblob WHERE id = '$bid'"; $imageQ = mysql_query($imageS); $imageD = mysql_fetch_object($imageQ); header("Content-type: image/jpeg"); readfile('path/to/image/test.jpg'); //<----------UPDATE //print "$imageD->bbblob"; //comment out ?> Now that should work.. if it doesn't comment out all lines except <?php error_reporting(E_ALL); header("Content-type: image/jpeg"); readfile('path/to/image/test.jpg'); //<----------UPDATE ?> that has to work.. if it doesn't the image path is wrong (removing the header will show the error).. (fix and re-test) Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/#findComment-929694 Share on other sites More sharing options...
awebbdesign Posted October 3, 2009 Author Share Posted October 3, 2009 15 min break and I have fixed the error.... <?php header("Content-type: image/jpeg"); error_reporting(E_ALL); ini_set("display_errors", 1); include('../../connect.php'); $bid = $_GET['bid']; $imgS = "SELECT * FROM $table WHERE iid = '8' AND id = '$bid'"; $imgQ = mysql_query($imgS); $imgD = mysql_fetch_object($imgQ); print "$imgD->ablob"; ?> It had nothing to do with the blob page, believe it or not my connect file was to blame as my <?php start tag had a space before it, causing a header error. I removed the space and now works perfectly. Thanks for all your help dude. http://www.awebbdesign.com Link to comment https://forums.phpfreaks.com/topic/176380-solved-image-from-blob/#findComment-929703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.