473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do i display an image from the database?

2 New Member
Hello I am new to the database world and Ive learned how to do a few things storing text is easy. i found that out but trying to get an image to show up on a page is difficult and i cant seem to find the correct way to call it up in php so it will display..What i am trying to do is build a search engine for a furniture companys rug collection...so that the rug type style size and an image next to that will show up...

this is my php code
[php]<?php # rug search_results. php
$connection = mysql_connect(' *', '*', '*') or die(mysql_error ());
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db ("rugs", $connection);
$rugtype_id = "";
if (isset($_GET['rugtype_id'])) {
$rugtype_id = $_GET['rugtype_id'];
}
if ($rugtype_id != NULL) {
$query = "SELECT * FROM rugs WHERE rugtype_id=$rug type_id";
$result = mysql_query($qu ery, $connection);
if (mysql_num_rows ($result) > 0) {
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
echo "{$row['itemnumber']}";
echo "<br />";
echo "{$row['rugname']}";
echo "<br />";
echo "{$row['origin']}";
echo "<br />";
echo "{$row['fabric']}";
echo "<br />";
echo "{$row['image']}";

} // End of WHILE loop.
}
else { // No
echo '<p class="error">' ;
echo "There are no rugs listed for the given request.";
echo "</p>";
}
}
else {
echo '<p class="error">' ;
echo "Please select a valid rug type from the drop-down menu in order to view the rugs.";
echo "</p>";
}
?>[/php]please tell me what im doing wrong any input would help thanks

Dan
Feb 27 '08 #1
5 1344
Markus
6,050 Recognized Expert Expert
Have a look at this tutorial.
Feb 27 '08 #2
ronverdonk
4,258 Recognized Expert Specialist
Welcome to TSDN!
please tell me what im doing wrong any input would help thanks
What you are doing wrong anyway is NOT enclosing your code within coding tags! You make it hard on our members to help ytou when you present them with messy formatted code.

See the Posting Guidelines.

moderator
Feb 27 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
Your thread title is 'How to upload an image blob', but from your code the image is already in the database and your question is about displaying an image.

If the latter is the case, you should have a look at thread Showing an image from the database because that handles this problem.

Ronald
Feb 27 '08 #4
howzy
2 New Member
thanks to all

yes the image data is already in the blob. But all i seem to be getting back is what looks like binary data and not the actual image..i would love to know if there is a way in php to bring up the image. Most of the tutorials i found are how to browse and add an image to a database...i just want people to do a search and then have the image of the item and details about the item to come up. so far i can get the details to show up but im having zero luck on getting the actual image to show.

thanks
Feb 27 '08 #5
ronverdonk
4,258 Recognized Expert Specialist
Look at the thread I showed you in my previous post. Exactly the same problem.

Ronald
Feb 27 '08 #6

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

Similar topics

9
1966
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual Basic .Net application. I have researched MSDN for help and found the example article 321900 (see below) and set up a test and everything works fine when I use SQL Server 2000 but when I modify the code and use data from Access 2000 using an...
1
4413
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail image in a byte of what is in the database. I also want to be able to display this image in an <asp:image></asp:image> control. Is there any way to do this? Most of the examples that I've seen have used
1
2947
by: Eric Keung | last post by:
Hi all, my case is I want to get an image from access database and I just know it's "OLE object" field type at access I also don't know how to insert it into access here is my code and it just can display a invalid image try dim strConn as string strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath
5
5048
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page that calls the web service to render a vertical strip of images. After doing some research I am unable to find some vb.net code that can assist in what I want to achieve. The closest thing I found was
3
5248
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from database and display it in a Image web control dynamically(at runtime). The process after being displayed in the web control, user click insert/add button, it converts the image(jpeg) file to bytes and store it the database with Image or VarBinary...
1
2337
by: Objectifnet | last post by:
What I really want to do is to be able to link two pages together using an ID, The table involved displays an image stored on the File Server that has the image details stored in the Database called. THE Database used is MySQL "Support" on a Table Called "profiles": The problem is how do I get this piece of codes to link to a details page called "PATRONS_DETAILS.PHP" and display information about one particular database detail. With ID...
3
6448
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating imagebuttons which point to a dummy page that takes the image and displays it via response. All works fine if I use explicit paths to a file (response.writefile(<filename>) or directly pass through the database image...
7
5411
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed to show the image, and an image.php page that accesses the database, retrives the image data, and then (theoretically) prints the decoded data to the page. below is the view.php page code: problem area the img tag src no
1
3381
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>
1
2047
by: swethak | last post by:
Hi, I write the code to display images.But it will not display image.And also gives the error like that error : Notice: Undefined index: gim in F:\Facebook\pic_up.php on line 59 plz tell that what is the problem in that code <?php
0
10323
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...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
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 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...
1
7613
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
6847
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();...
0
5515
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...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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
3809
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.