473,715 Members | 6,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in displaying images from database

5 New Member
Hi!
I am having a problem in displaying images from database.
This the code


gallery.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['$signin_name'])){}
  4. //die('ERROR:'.mysql_error());
  5.  
  6. $host="localhost";  // Host name 
  7. $username="root";   // Mysql username 
  8. $password="";       // Mysql password 
  9. $db_name="task2";   // Database name 
  10. $tbl_name="imge";   // Table name 
  11.  
  12. //------------------------------------------- Building Connection ------------------------------------------//
  13.  
  14. $con = mysql_connect("$host","$username","$password");
  15. if (!$con)
  16.   {
  17.   die('Could not connect: ' . mysql_error());
  18.   }
  19.  
  20. //------------------------------------------- Selecting Database -------------------------------------------//
  21.  
  22. mysql_select_db("$db_name", $con) or die(mysql_error());
  23.  
  24. //----------------------------------------- Selecting 'Filename' form 'imge' -------------------------------//
  25.  
  26. //$get_image="SELECT Filename FROM $tbl_name  ";
  27.  
  28.         //mysql_query($get_image) or die("Error:" . mysql_error());
  29.  
  30. //$path= mysql_fetch_array($get_image);
  31.  
  32. //echo $path;
  33. //$image = stripslashes($_REQUEST[imname]);
  34. //$rs = mysql_query("SELECT Filename FROM $tbl_name WHERE filename=\"".
  35. //addslashes($image).".jpeg\"");
  36. //$row = mysql_fetch_assoc($rs);
  37. //$imagebytes = $row[imgdata];
  38.  
  39. if (IsSet($_GET['pixID'])){ 
  40. $rs = mysql_query("select Filename from imge where id= ".$_GET['pixID']); 
  41. header("Content-type: image/JPEG");
  42. while ($row = mysql_fetch_array($rs)
  43. {
  44. print $row[$imagdata];
  45. }
  46. /*gotten = mysql_query("select Filename from imge"); 
  47.     header("Content-type: image/JPEG"); 
  48.  
  49.  while ($row = mysql_fetch_array($gotten)) 
  50.     {
  51.         print $row['imgdata']; 
  52.  
  53.     } */
  54. mysql_free_result($rs); }
  55. ?>
----------------------------------------
Displaying the images in this file

your_gallery.ph p

Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <TITLE>Your Image Gallery</TITLE> 
  4. </head> 
  5.  
  6. <body> 
  7. <h1>Look at this:</H1> 
  8. <?php
  9. $host="localhost";  // Host name 
  10. $username="root";   // Mysql username 
  11. $password="";       // Mysql password 
  12. $db_name="task2";   // Database name 
  13. $tbl_name="imge";   // Table name 
  14.  
  15. //------------------------------------------- Building Connection ------------------------------------------//
  16.  
  17. $con = mysql_connect("$host","$username","$password");
  18. if (!$con)
  19.   {
  20.   die('Could not connect: ' . mysql_error());
  21.   }
  22.  
  23. //------------------------------------------- Selecting Database -------------------------------------------//
  24.  
  25. mysql_select_db("$db_name", $con) or die(mysql_error());
  26.  
  27. $strSQL = "select * from imge"; 
  28. $rsPix = mysql_query($strSQL); 
  29. $numRows = mysql_numrows($rsPix); 
  30. $i = 0; 
  31.  
  32. while($i < $numRows){ 
  33. ?>
  34. <div style="width:33%: float:left"> 
  35. <img src="gallery.php?pixID=<?php echo mysql_result($rsPix,$i,"pixID"); ?>"/> 
  36. <?php 
  37. $i++; 
  38. ?>
  39.  
  40.  
  41. <br/><br/><a href="upload_view.html" title="Back">Back </a>
  42. </body> 
  43. </html>  
  44.  
Please help me!
Oct 19 '10 #1
3 1702
code green
1,726 Recognized Expert Top Contributor
You haven't stated what the problem is
Oct 20 '10 #2
Shenno
59 New Member
small x mark appear is image place ?

browser outputs very big strange string ?

do u use IE or FF ?

view source of page containg img tag contain the information u expected ?
Oct 20 '10 #3
Hataf
5 New Member
Than u all
I have upcome with the problem
Oct 21 '10 #4

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

Similar topics

11
1979
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'; }
3
5468
by: Kidus Yared | last post by:
I am having a problem displaying Unicode characters on my Forms labels and buttons. After coding Button1.Text = unicode; where the unicode is a Unicode character or string (‘\u1234’ or “\u1234”) It seems to work the first time I set the button to the Unicode character. After a while, when saving my code, I get a pop-up window stating that I need to save the file as a Unicode else my changes will not be saved. Seance I do not want...
0
1476
by: Matt | last post by:
Hi I'm have difficulty displaying images that are stored in a MySQL database. I've tried using the odbc.net provider, the ByteFX provider and the MySQLDriverCS one but can't seem to get the image to display on the screen. I've tried searching on the net but can only find examples on how to do it on SQL Server and havent had any luck converting them to work with MySQL. I thought I had to put the data into a byte variable then use
2
2585
by: Jeronimo Bertran | last post by:
Hello, I am using a rendering aspx page to display a database image on an Image control. When the database record is retrieved, I am saving the bitmap to a session variable for the rendering aspx to load. Here is the code on the rendering page: CODE FOR ImageForm.aspx private void Page_Load(object sender, System.EventArgs e)
3
1523
by: active | last post by:
I draw text in a bitmap and then draw the bitmap on a picturebox and get text that is not all displayed the same. Note the different text style in the (40, 100) area. Got any insight into what is happening? Cal
0
1139
by: hali | last post by:
Hi all I'm working on jsf & I have a problem displaying a list of Items via hand set my code is: <wap:dataTable value="#{predefinedESP.esps}" var="esp" > <wap:column > <waputputText value="{esp.currentText}"/> </wap:column> <wap:dataTable> my problem is that the list of Items displayed in one long line and I need it to display each esp.currentText in a new row
10
5756
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the images) of the gridview come from a single table/datasource. Here is my situation. In my web application, I need to display customer bills info in a gridview. Customer names and contact info are from the Customer table.
2
1670
by: mwgjr | last post by:
Problem displaying a graphics form from another forms button click event without losing the XY data plot. If the Startup form is the GraphWindow form the Graphlib.vb calls create a XY data plot. Code outline (not everything included): (Sub GraphWindow_Paint(ByVal sender As Object, ByVal e As SysPaintEventArgs) _ Handles Me.Paint) Call Graphscale(xmin, xmax, ymin, ymax) Call DrawAxis(10,10) XY data Call GraphPlot End Sub
0
8821
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
9196
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
9103
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
7973
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...
0
5967
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
4477
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
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
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
3
2118
bsmnconsultancy
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...

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.