Hi,.
when i display the image by using below code i got the error as image displayed in the form of garbage value format.plz tell that what's the mistake in my code.
[PHP]
<?php
mysql_connect(" localhost", "root", "root") or die(mysql_error ());
mysql_select_db ("rainlist") ;
$result = mysql_query(spr intf("SELECT * from pix WHERE pid = 1", $_GET['pid']));
echo "SELECT * from images WHERE pid=".$_GET['id'];
$row = mysql_fetch_arr ay($result);
header("Content-type: image/jpeg");
$image=$row['imgdata'];
echo $image;
?>
[/PHP]
5 2223
hi,
i wrote a code to display multiple images.But it display only first image.plz tell that what's the problem in my code. -
<?php
-
header("Content-type: image/jpeg");
-
if (! mysql_connect("localhost","root","root")) {
-
$errmsg = "Cannot connect to database";
-
}
-
mysql_select_db("rainlist");
-
$gotten = mysql_query("select * from pix");
-
while($row = mysql_fetch_array($gotten)) {
-
echo $row['imgdata'];
-
}
-
?>
-
Markus 6,050
Recognized Expert Expert
I've never had this problem, as I've never been in this situation, but my guess is: because you're using Content-type: image/jpeg you'll only be able to display one image.
Markus 6,050
Recognized Expert Expert Atli 5,058
Recognized Expert Expert You've posted this again
Don't double post.
The two posts are indeed pretty much the same. As I see it, they describe two different attempts to fix the same problem.
I have merged them into this one.
Please try to keep all posts regarding the same problem in the same thread. Even if your attempts to fix the original problem are causing completely different errors, just post them in the same thread so it doesn't get scattered all over the place.
Atli 5,058
Recognized Expert Expert
The reason why the code in the first post is generating garbage data is that you are printing data before you tell the browser what type of data to expect (that is, you are printing the query before you set the content-type and print the data). When you do this, the browser will automatically expect HTML data, which will display your image data as random hex characters.
For example, this will cause the output you described: -
echo "Hello!";
-
header("Content-Type: image/jpeg");
-
readfile("someimage.jpg");
-
While this, would show an image: -
//echo "Hello!";
-
header("Content-Type: image/jpeg");
-
readfile("someimage.jpg");
-
Note, that the only change is that I commented out the echo statement.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ian Davies |
last post by:
Hello
Im having problems displaying my images as thumbnails in a table. My code
for producing the new width and height from the original image is as follows
**************************************************
if ($ImagePath) {
//$Image = WEB_ROOT . 'images/PupilTester/' . $ImagePath;
$Image = 'images/PupilTester/' . $ImagePath;
} else {
$Image ='images/PupilTester/nopicture.bmp';
}
|
by: Balamurali C |
last post by:
Hi All
I'm having one problem, since im debuging this last one week I'm not able
to do.
Problem:
In my webage I have two Frames(top & bottom) in the top frame I'm
displaying some images(logo...etc) and bottom frame I'm displaying some
document(excel,word,ppt,pdf etc...)which are working fine.
when I take print, using IE-File-menu (IE->File->print) when excel document
|
by: CLEAR-RCIC |
last post by:
I have several images i want to display in an ASP.Net application. The
images are being passed to me in binary format from another application. Is
there a good way to write them directly to an HMTL page without having to
save them to the server and create a URL to the virtual directory?
FYI: I currently am doing this with just single images. I do a
Response.BinaryWrite(byte) to display the one image. The advantage is that I
never...
|
by: David Lozzi |
last post by:
Hello,
I'm wondering whats the best method to use for displaying several photos'
thumbnails. One method I know is to dynamically resize the photo at the time
the page is loaded. What does this do to server/site performance? The other
is to copy the photo at time of upload and create a thumbnail then, have two
separate images, therefor when displaying its just pulling the actual image.
What do you think??
|
by: CD |
last post by:
An application is logging faxes sent in SQL2000 image column type. I have
found code on the net but what it is doing is prompting to save to local
which is fine for single page image. Not good for multiple page faxes. I
have not been able to locate an example to load in the browser or how to
handle multiple image in the one column.
1) Ideally it would be nice to display back in the browser since some may be
multiple images. I am not...
| |
by: DumRat |
last post by:
Hi,
I want to run an animation(in essence). I want to draw multiple images (possibly .bmps, but I'd like other formats as well.) on to the screen each frame.
I tried to do this with some C++ code, but it isn't working as it should (As I'm expecting it to I guess.). Can anyone please help me?
Here's the class definition. Just for the variables.
class CWorld
{
private:
|
by: vozzek |
last post by:
Hi all,
I'm a CSS rookie, but I'm stumped. Hopefully this is something simple that I'm overlooking.
My master/detail page generates the following html code, and I've got it formatted with CSS instead of tables. I have a wrapper that's 800px wide, and I want 4 columns of 200px. Each item is an image 160px wide, with 20px of margin on each side.
Seems like it works for about 3 rows, then it skips a few (three items). Six rows after...
|
by: littlealex |
last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS!
In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly?
http://geekarama.co.uk/new_home.html
here is the code for new_home.html and following that the CSS...
|
by: swethak |
last post by:
hi ,
i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my local system that validations work.plz tell that whats the problem in that.
Here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html...
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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 project—planning, coding, testing, and deployment—without 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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |