please help

i need to retrieve image from data base

<?php
                        $sql_img="SELECT * FROM packages_image WHERE packageID='$pac_id'";
						$sql_img_query=mysqli_query($connect,$sql_img);
						while($result_img=mysqli_fetch_array($sql_img_query)){
						?>	
							<img src="data:image/jpeg;base64, <?php echo $result_img['content']; ?>" />
						<?
							}
						?>

Open in new window



it appears like that

�A��7a3_3+��i�G��VX�$T�[T}� �\.����m��H��帢��Q��l%��c:y�*�M0��?�8�zq����i�O���;��z�s����Yg���vtl+-�:����ק�j��#u�c�|�EX�D��O{���������<��L��KSi�+���Ui����lO_ڏ�y��t٬r�e[fG���*�-z)�ְ�IS3�>����Y��寕iOy������.���f/b�,�^F�U��6<�nS�h��ȖX�D� /�\( yXe�8��_���t�jڌ���d5;bRE�əs�\��3�Q(d 8b�)]8��t�.�eӊ�՘ z$!zq�N2��F�c��!̳��A�H�B�� B�b�����X\���X\���X\��J�Fo}��)�J�����K����=���'!102 "3AQ#@��?�C�ר�a׫�Y�cX[�S���#{D�g�1;G@��D���H����A�1F��RlCE�2e��~"9.D_�Uo���V ϥ�5nc`M��#cxl�">;(����-"#���Ӿ�8�_!c�*3M%��4����nx��_r�P��S {��u�A`�ǶB����n"�Sᬟ��x����"� :n�%n�5�o&�b&!J�g*��Q>�QP�[����M�E�c��f��D-H�Jlm�Ʀ��� ����y��� {f�=�E`@ � ���<��.�a?��%!1 "023Q@a��?��6#�Q���Tw��q�b� y����"��=G���OQ�9��D���"�u��(�0x��cj�6�I���(�D�#��A�ʃ-�b�*�祎5nc��2����"=�0Qa��,7�ZD5�k�^yn��!n���4��XZ�M:]���+��P}����\��~c�-�&��+TS񪒯������L(ɺ̔�)�������U=�Ua��l��B6��N0�J��"����Z��]O"���E@������ ����q4V5m��<�� �*M��� q��5 !"12@AQq�03ar��� B�#�Rb����?�������j�nv�ۭ@���J�da��`#A���dT�ĂT���d-��ؾ\�l�2[c�O(�܍42�NA]�m��ȝ~v�ȝ~v�L��_"��G��\"���O�y���P� yOn��k-�V��E�ZDz6��c�"������mK2UF�2���%��ʨ�C��&Z�� � u��Yk�=�� ���,�����R����M0��tS%��-�%�_�Z���#���:K^��U�Ϫ5NP�h`Fn�ˬ�����C;x�+��O�h�Ѣߦo�7)��}2~>��i0"҃�^jW�Z���>��'�|љ���.���o�0�^h��������,/J����s1n�-�8Fg@A�Q;��gt������~��O�wI������wA�� ��S��jxJ:�伦+q} �r�3Y�f����.6�����Ǚ�h�;�i�eJ�1&��0��>�P�X„P���,OP�7��at�=�f�'�.#�<�.��2��p�d� ;�,�5iX�YB��@u-�ƊDfSQ-��duW�?4��<���a���f�׊؎�&&*p⑧|�OY���Y&�Md����a�% �I��Y!F�1�n�o�L�OX�Y05���)�ji� *�s���S�j{���j{�Oq5=��Z v�*),��� 0��߶�%O9���uo��)!1AQa@q������0��� ��?!���@���w��n'�~�q]Fgn{�)��.L�Xj(��)l ��MD��*+��@m��ؘw���D����sA����Y �L���l����Иl���|��ؘl����8�� 7�����%�xa�n����Cd��\��9�yZ'*�*!�xZNI���i��Q�e"��(�h�O���eO�l��O�!J��x>��@^a�؅thD0 I�W��"u��B������`ߙ�ɷ��T��*�ٹ,�p�R�'&�*5�y�N]/9J���KA����_�%j���1�=��ux° {Wh?�v�����5^'�,p'���WR_I��i��i�Y��9!\�aA�X�=��O�{B�t*=��2Z���<#�xG��oy���Cn|2㢬}�!�Ȝ#��@#`Տ�"i�i��A�r���� ��<��<��<��<��<��<��<��<��<��1��<��<��<��?��<��<��<�<��<��<��<�<��<��<����<��<��<�����<��-��<�P|��<�����U�Q��<� Z�������?��|���D|�x��u��C�� {M��9:�K�{e/�\�����&!1 0AQa���q�����?ܭ&�Fqw������7ƗY_�+N�VԲ�K�v���ghn�w��{ �;�)�Cm^Ӡ��q�q>�+z.���\SH�п3��%�a�1;!�?�4��0��. �Y� �dL���c[9�ӌEf/64��j�b���mL�d�(�>1�R�[�h�Q�p���1C,A���o�m)c��/h<����"1�^bX0�b�r�^a� (yy�߳���IBA-#`��`���~Ј�w2-��)�c����>�N����>�A���%!1A 0a��Q��q����?�N���� ��`Q֨%X��EgU,���o1�<����ܠ���SЂ��t �c5��E�������H�пs��J���/Jc0yC`��q��~�R�|D�m$��ڸVK��u�Ƨ&�� h��8^&k�U� ��p�WR�[�}DKGh{D�v�-D���{��pM%f]�_������!(?�'��"�+E����K����<ɦD�`�)�m�q�� !�g�� ���c���w��a���)!1AQaq����0@����� ��?�1 �^!���O�ir�{�{~�]E�B z�>�-���"��o�tL�{C鎤�Ք��#X=L#��4#T���s�4�l� a+ʲ�j��WQJ���,4 gvjsUL0|ϼ���:uS�Lh�S�|� A/�z�&@���S�2h��+H*#���D��}W�Q$�fϟ����x�(����H��m�1WeB�>�KS�I����Ow�*��oZ>R<���ؘ����H�Wŗ�Q�{q�����o��dV���|��9�@@��}��K��8$��s� �Ӥ�\}��!�϶ � ���0 �OO�T��xj��"�H�|�`U��`Ȟ���N@���i��������)cI�����N&ͯ��f�k��\#�q"KI�������I*5F[��"�9 XA���&�� ��d0�0��6� f�"'��EB������%�e+ ���^d���<5�c~x 4����$��I��k�U&���|{|�A"���.ORR���=�2��D�$!��cP�Eܓ��ED�trj;cc����m~�p\���dyI�^� %�q�8��� �̔��Ƭ�D���lq�=��n�u鄱(�~������l*��*1 ��}��������� :��r��ɝd��Ȯ��q�8r��{��rg�cp�qWNGq����X��p5����cPr8�Ӷ|����k�9��n��/�|���!�g =*51������kEI �Bv���6��C$¸���^����1���9ׇ�2��/�����Pv+��LIg��� @$N���,�>���p��*�/�|��i�+�y�ۀ������x�Q0�s���+�����s:K���!��W�>9���m�0�ԙ.��H6XQbn��ބ�'�_��ۭ�lk�1+UH�͝;�z>�P�9_�����FLq�c���ň$7O���4D����R�|��^㎙�M�fޓ���B8�ժ�7C�Sʡ���a&� "�T�l3�x����::Hp�U2$|w�F�P����Oa�����?' 4d�>o:b�%6:{`y ��yg&�8����舟�w�� X-ˑT%g��8?v��8���p��FULG�� �W�=����";��:�2Rh�;Z��/X�N�;� !� /K�u]� ��TJw?��gF���a(�[� �U��O\S��y2�trG�׏�@0��C~~x_��I�0���<;&Z�l��<�:x�=bǷ8�D�dk��r���C,%V �ea�" e���n����C�=L��7�8(����u����랠�o�� �#����Ԁ��,D����=;�#���lP$"I'��I�f�C 6����D�� �'X��#E�w�89 �'��'hm̺s���kj=Z�|�T����uy6yv�K0�=�a$��f9mؕ����dt��#9 i�� Ԓ�rS���!��#�� ���'!�2P�~��l����&LVq?'���5[Rg�雥�I�Z�#��'��ѩ�Hk�1tVl5��}��U#�����P ����|��Tn���,��=�|��GJd�Z.`9��8�"�溤{y�� �'���S�pQ��vQ���CMnYJ+D�ח|� t��2��ɲzǷ��%��a܄!N��W�C(A��uy�;���M����Y�Xx��B F�*�����C�C�B-B�{�M5'���%��r����\x����ۻ�� ��.q�����+�� �v-B�;��@�@�6�� p�=��� �3hc"d#^F ������~���" /> �f?��w�� 7?�����'�4�O�������?�~�ޣ�g��Y������N?�����?���Q��Ex�מ���y4\������Q?���='�5�����ɏ��^/���t}����?���{Dߵ��0|����k��ᨿ������^k�Z>���Vdo������j/������k�����9�����^-�y��}����9�y?�������w������)^w��$��9�PfW�j�?j�?j��W����7���}o���|~e����Et65I�z<���!|Z���.K�k:n�?��y<���������>١���I��O� }��*X�������U�SU���z��}}y/��'��e�ȕ��T��ϫ�����s�C��s�_�����_Ēӥ�����˯��$�fA���>�����|X��̞�I�����4���:��X�VmR�?�o����O����I+�?�y>g�<ڒ��Kȿy$�}]��rL$���Y�g����� '�5[k�+�� �U,_�νjI7����� |B�~��Z>��i:�_��iy$R�ԟஞ.�{�{O���K/�|��Q�9+/�S>c��~�iy�� �x���_�U��S��r�y~d����/�g^�g�u�}�9�UhԥS��GI ��}��g��dž��U$7�S2=ri�uT暉���M]�sMU暉��GZ�&�W������u���3w�xn�O/P��Z���ӯ�?�_��L�Ϸm�ٶ�M*p2���:��-c��Ic��yתi��L�Ŭ�c��y�_Nx;��i������N��W��ͪL�# �P�=O����'�� �����|K�$���H��*|~��/�2�g?n��&��S��X��T*�w W����?�+���n�H9c�P��e})4����Q�|��W\���-��<��_���˿� ~M��!O.t��}���o�7��|�~�Z��h|�R9$�_��]~�|���#~����_�%|�W�?x�z~���Rh�x��i�jC��?����t�����\�˛�[?��M�Xp�'���Z��V��f�1��*9�C-g�iI��:̼�g��ǙEC��3�I����i�p?!�,���&���YY���Z?��m/�b�^�6����z�_;~� ���ᦡ����~e,-^L@�����?7�����L�U�1���5/���?�^I��<��X��RH���$����2�O��I���� �qO�� �U9�U���B���]]��s��3��4���T*�������������~����GK�RI�d��^w�OǗ����?��L���Ҽ4��<�t����|�����n��5���w>\q��I#��}�c�F�"~�ח�%�?�*��5)�[�u/���q���^٦�ǯ�ɯ��Us?c�i�:�>k����U�#�u���Πa�'�������湣x��?E$~^�i��,����������׏��O�~$k:��Ϋs�=.�̏�j�͖�O���=?��}�>�>��<����T���|+��W�ON���8j�:����������5-RK V JE'�����b����[��b�mי�����Y�6�����F'�g�^�����5 9���K�$�U������Z��.��__K}���>���ߺ�O�>�����E����Y�����_���~���R�M��y^�#R���3�Y.�&�#�=��S��\��T��]_n2��^��'���?�����^�?j��ro� ^i[?w-��I'���66�����k�3���\�;�K����T���g�<���w�4"�7���O�Z�$�_.Y<�$��>��5+X�y����8og3���!s�!�󿂬C����Q��$��C[�̖��jt�oڜũ��t!?����q�\���C/����s�v���.�������_���� ��is����价�(��*��=�=9�3��V�qga�l�U\G��Cu�����_�V��Z� ���Ic��~�Z���Uc�Xy{.������o$r�u9?��Ӈ�S�����AK��5b�A�G�[�'Ñ�?�s]ЧZ���<ڵ*S�rw�jY�\����md���S}�.���>$&��ˉ���Q�5CF�us���l������G�q�'����>��3�z�_�z?���K�%ƥk=�rK'��#����q��d��K�̖_�x�y%{xl��+¡�_q5��J��9��y޳��Z������������oo��g�I���c����篕'�s�+�Mc����_����$�<]�I"Gm%��g�$����SO�b �R��^����W֟���D�X��y|�����>�z�?I��1��|�W��a����� ��O��?N4c���)���$����W�|1��ǀ�ο��_�^$��_��\q���|�C� 5;�'�/�Pk�y~�?�\�m��uܒK�x�����K���4i�K�O}���k��m����\���~g��V����{:�������^ZImmqk��.���A�k&y�_3�_�%hh>���p]�_}��ZI��~��X�,�������(��Κt�����6I]�����y�'5�&��I5����?���>���J?矗\���O����h:7��W�ߴ���&���?�u�~֟����,|�.8�������m>�}$rI/��k��ὥOhxy�;�P�f���JK?�1������O3���y�O�:��l䱞[����?G�����t�_�I��:���|U>���y$���H���$�˯��L�C�){O�|Oک�ڬ^w�s��L���0����n'�%�?/�Y����?�i x�I�g��9d������8�6�q~�͏�e~m�ٚ;���O=%����_'��K�3��*��=�����z���d��G��RY�y�'�W5���g�Xsy�c��M(�L� Wٳ�O�G����.�����~ez��ğh�$�G����˿ ��$������)!���w,��J�,v]R�?C�szs���|ӡ�� o3��G]g�~��`�$��?��u���X��/1$�*�=�k���y�d��Ҽ�g���r@�?�X����z�I<���U�5+�?������F�� G�uO�5)d�Y��?u]�:i�yrI����֞$����x>Y$I.e���d���-t \j^g���W�#�F����~�+�?�_����$�`��;�g%gK R�C���B��c��_��O�5 <�/�%x�������ĚĚ�י$��k.k���_m��{:g�y�;��.Y�$W?$�⾨��u�� g̵K��]I�������q��z?�}G���3��?c���x��'����yu�T�<����Uy�U��{G��]'�̽J�΋˒����xU4�?/��������/*������+��(��oYy��c��Zy�U_*�<����,�������k�o�,�~�X�?R�����s�:f?�$�O���-*Ə�]�K�I,q�w�?� ��N�����U}�� �9]�?������wUv���ڌ�Tc�w1�_��̯��Կ{�<��>*�������y5r�g���>�пh�W��I}s�K��<�Cڧ����t�'���=+?�����V�l^Y� _r���A�S�dBH�U/�M/���Ky�>����泸���s����@�G�<�yQ��l���*;�2iw�$��G������r;ɿ{�<��iRC7���Tvp��D���Z'��Uji��y�'��� ��F���n{���D�_��Y���Xg������������t۽b]>K_�K$Q�%ĐI��O��%|ϣ�1��-��y���y�d~_�_����Wٟ�O�缊�y ���q�~_��]e�;�������45�yg[�C��Ϛ�:NOR�|���Xw�K;#�lq~��Jγ����>c���&��;T���#�;�/��W�_������y���'٣������3��u�����_l𼚗�㲎��wI$qE���O���w�Q�gk(�;Y㾒Y?�G�y�l�*�3�z��u⹹�����ezG�<+�߹��\~�g��=���sw�~L��������t������i��%g����2����7�7�����JІ$���G 2C1�$���Y��yrU�l��|��gF�g$�\�ehC��L�i�i�X�'���>�>����n?��<�?y���O���d���������YW��7�^x�=*�O�˩<���#��������P�'��}K���Βˣ��~���,���O�_\|1�ci��X㵃ˎ/3�"W7���-��a���够�ҽc°b�:��>���MR��J��,���yU����z�� ǖ� ��Ȗ���Y�G�-��u��}������>cȞl���y+@>G���ƿ����������̷���V���r��I���v�JM��O3�wr���u��� C7���W�GO�V���ٟ��d[� �C�H����������?�|��#�����I ��Y+�#�����. �#���g�?�W���'�g?����#��"��ˎO�E�G'������?���J|����������X�� ���N��ξ��'��R���f����˒�H��Y�]+����sR�n�,o��mR��e�����uň�R�ۆ�����t���ʱ���|��엟��n��˓��W�-b�M�Cq�����ˎ����θ��w}K��p�>xe�bf�4���j��$��l�ꏆ�����}�U�g�M�i<�> #�b���Y%e����O#��wRI���?2�i��?�U*S8�����ܗ̵��u�|f�����w�%��n>����ؿy^���?��y�A�|_�?�?���,��M7�\�}�D��?��yq�]���9�3��bߌ�<�ž��������_����f�g��뛇�uӦ���`�������aԴ�c��S���wq��_��EZt��ٗ��������CW'�U��Y�45��W&���hg�g�Q����<�7�}�?SZ��?���W��|U�������9?�R�H��=��آ�y����� ԭc�O���?_�ι�~��o��#Yӿy�-���"�����k?:��)����������oԾ��8�Aۼ?'ٴ��#��ԟ����W�~����h?�<���N.��G�O�p���Wؗ� $��K�[k��d�-����R�O��V&�R?�qS�S�Ohv��ԩOٟ3�`���u�=7ȹ�͸�H�?����H�w\�����J�|Q��wڽ�_��K�3��?秗�=+�MKBK�c�<�?�Ս�i��yu��N/fy~����r���q���g�����? �1}���S6����i��X�g���LU����J� ?������?��" />
AHMED SAMYownerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
The value of $result_img['content'] seems not returning valid data needed for base64 image?

can you do a try and see what you getting from the result here?
https://www.base64-image.de/
0
NerdsOfTechTechnology ScientistCommented:
You need to use base64_encode() to encode the blob output.

<?php
 $sql_img="SELECT * FROM packages_image WHERE packageID='$pac_id'";
 $sql_img_query=mysqli_query($connect,$sql_img);
 while($result_img=mysqli_fetch_array($sql_img_query)){
  echo '<img src="data:image/jpeg;base64,' . base64_encode($result_img['content']) . '"/>';
 }
?>

Open in new window


http://php.net/manual/en/function.base64-encode.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Another debugging trick you can use to expand what NerdsOfTech suggested is to take the write your base64 output to a file + see if you actually have a real jpeg image.

You should be able to take a jpeg off your disk + write it to your database + read it from your database + write it back to a file + then render the file in a browser.

Also if you copy your output to a file + can render it, try running the file command on your file to see what magic number lives in the top of the file. This may provide some additional debugging info.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.