473,657 Members | 2,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To Retrive Images from DataBase

25 New Member
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 1708
pbmods
5,821 Recognized Expert Expert
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 Recognized Expert Contributor
Hi,

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

This should get you started.
Aug 30 '07 #3
pbmods
5,821 Recognized Expert Expert
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
1357
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 tables/chairs for a exhibition, some small images represent tables/chairs of various sizes/styles, which considered as movable components in this GUI, and their positions specified by X|Y.
0
1247
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 this in the database(x,y*x1,y1*x2,y2*............)these are the coordinates i want to retrive from the database. thanks .
8
2528
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 problem for me... but how can i write that string to a xml file....
1
1127
by: damodarraoaadepu | last post by:
How to retrive images from database (sqlserver2000) in Asp.net?
0
1606
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
2981
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 image upload in database: -----------Upload.jsp---------------- <html> <head> <title>Account Details </title>
3
2084
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")) { $errmsg = "Cannot connect to database"; }
1
1762
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 retrive the images from the SQL Server 2000. if there is any sample or example of the VB code please send to me. Thanks in advance Mahesh
10
7261
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 other location at the same time.. i successfully created the applictaion .. using some serialization concept (BInary Formatter).. But the main issue is that .. it isworking very slow. it take too much time around 30 - 40 sec to display image on the...
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.