473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How To Retrive Images from DataBase

25
I wrote code like this to retrive images

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  mysql_connect("__MUNGED__","__MUNGED__","__MUNGED__")or die('unable');
  3.  
  4.  mysql_select_db("website");
  5. $pid="151";
  6. $gotten = @mysql_query("select title,imgdata from pix where pid=".$pid);
  7. if ($row = @mysql_fetch_assoc($gotten)) {
  8.         $title = htmlspecialchars($row[title]);
  9.         $bytes = $row[imgdata];
  10. } else {
  11.         $errmsg = "There is no image in the database yet";
  12.         $title = "no database image available";
  13.       }
  14.  
  15. $i=1;
  16. if ($i== 1) {
  17.         header("Content-type: image/jpeg");
  18.      echo $title;
  19.         print $bytes;
  20.         exit ();
  21. }
  22. ?>
  23.  
it is showing output like this
=======================
Expand|Select|Wrap|Line Numbers
  1. TESTINGJFIFddDuckyAdobedۄ  
  2. #%'%#//33//@@@@@@@@@@@@@@@&&0##0+.'''.+550055@@?@@@@@@@@@@@@X "ĥ!1AQa"q2BRb#r3$C4Sc%5!1AQaq"2BRbr# ?V0{֔skW Kzx+S ʤNnphqa
  3. HM5bf>5oEhAWn;HvQ~ЄIųUEm;Aj ^朁Df%-S[:EA} { unݩ6Po~5Ic (?3(͆(&&-pqҥ0ȹSv3y!WJ1Kɸx]* b1z
  4. Y7ͻU=LSުVGzR1}~=mѾ    #J
  5. m1M/ sZYiw<Tt4`$ 7zaUJ"46RhY7\ \nZ)66⹶u)1pk5{XԴnb0z okvQ@:H Fz(VP؅#']7̇Lejq*nO|@)5˥j”lU,z՛bTt+O-ZI
  6. a*PiEЌ**=N&$ҐezկPA'*E[4Ƣ'Z*N*,45J-Q\1\hj1]bjm@*׮Eu]u@9[Ҋ#v* Zӡ1!.P*tn@8@EfIuU*@*uI4MҢu & Ԩ'JAցQa\Njvl4xr0m-Xd m7V &^),NmMqa"@@+;vF<eb~uybrp#T9#$ܳ]G)t,w)*U16jn5[+>b@AD29
  7. /%.aFw|o
  8. W    qlױ*H$Q'v{*;۽M-ULNbe+ 5hLa_vBAIeS꣆HX
  9. sN`
  10. ~ƜʋES|$
  11. sNRQrC\֚z8[q!]Zcl9ޖԉ8e:tZ&.͹B8 ߥJ^淌C
  12. E\U/ziν* U2'v,    SOMw…*ti4ќ\.2(FozaXZ
  13. Rů`D=J*b,PNAQt18"4~J$Gj[YܞH9 Gtޮp:M
  14. >Zց"H[wlems$:^!-Wšdޤ5o)Ի`~7ҀH    #=kf=U&ԯ)եmOڄQ]ФeѴd=zPyݟDnH?5mi:^E
  15. ]fPA.՟"    3 b*">:.ORt⛯rԊ2*10X    ż)rI:-?!&쁀ei~2mw[i֕`M*4*HZm|Kow|k$lm܀MLKŏi:
  16. C0'~ٚVm:u̚/lRsFn]l:tJ,lvz&oC%L^V֣a
  17. H+:T4Zzx%ޓh "TkVFOG[EΑvҒ4JPGɡ X0S
  18. H֬/21œM31'*sֆ0mZRbU+UQ1b/Du\*IM *c*qC E:X}j6ݺnƔXu UܓҸTQB11zi@@ ( 
  19. #M
  20. XМXf *jr
  21. [mF~Uk.t'@    һe\Z2therIƽh@T`t"R ܞ1qI9&\{P"5b:h?
  22. J
  23. Q]*h;iE9ҦeC3RZ'An3J#j_1ᇖź/A[atoܖ*]STkn64u+lw3! =TWCsX6ElxzMy"zF+
  24. Ʃf`ҶhHr-;@pyj49:]Un =A+/|?
  25. p?fZUgrTW*M)S!B
  26. 59 O)Ɵ?ٳD_#e +p
Aug 29 '07 #1
3 1685
pbmods
5,821 Expert 4TB
Heya, MMR.

When you set the Content-type header, you have to *only* output that type of content.

So if you are going to echo $bytes, you should not echo $title.
Aug 29 '07 #2
MarkoKlacar
296 Expert 100+
Hi,

what you have to do is create an image from string, or raw data that you get when reading a BLOB, using the imagecreatefromstring function.

This should get you started.
Aug 30 '07 #3
pbmods
5,821 Expert 4TB
Merged duplicate threads. MMR, if you don't start following the Posting Guidelines, you and I will have to have words.
Aug 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: john woo | last post by:
Hi I'm not sure it's possible that using javascript to locate/get components X|Y then other language, like java-jsp to save/retrive these data. For instance, a GUI presents a layout of...
0
by: babu | last post by:
Can Anybody help me about this issue, that how to retrive ole object(datatype) in MS Access database what variable i have to use to store data in VB.NET .The Format of the ole object stored like...
8
by: asenthil | last post by:
Hai, i'm having a string in a specific field of a database... now i want to retrive that string from the database and i have to write that string into a xml file.... retriving is not a...
1
by: damodarraoaadepu | last post by:
How to retrive images from database (sqlserver2000) in Asp.net?
0
nehashri
by: nehashri | last post by:
hi, I need one help regarding Asp with MsAccess database. Problem. ======== i want to retrive stored image from the MSAccess database using asp.
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
3
by: Eminosoft | last post by:
The below code can't take the images.plz tell that what is the problem in that code <?php // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","root","sreeni")) { ...
1
by: mahesh123 | last post by:
Hi Folks, I am using the SQL Server 2000 as back end in my project. I have one problem that saving and retrive the image from the SQL Server 2000. So please help me regarding the saving and...
10
by: sandeepdhankar10 | last post by:
hi!!! i need some help from the Experts Like u people.. i m creating a applictaion that transfer images to the webservice which store in server memory temp.. and retrive back those images on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.