473,372 Members | 1,254 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,372 software developers and data experts.

problem in displaying images from database

5
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.php

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 1686
code green
1,726 Expert 1GB
You haven't stated what the problem is
Oct 20 '10 #2
Shenno
59
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
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
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...
3
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...
0
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...
2
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...
3
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...
0
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...
10
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.