how to view image in Msql

Thread Solved

Join Date: Mar 2008
Posts: 238
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 5
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

how to view image in Msql

 
0
  #1
Apr 4th, 2008
Can anyone show me how i can view the images
which i sent to msql database,
i open the msql console, and type the folowing but nothing displayed:

>SHOW DATABASES;
>USE photos;
>DESCRIBE image;
>SELECT id,image FROM image;
then the id displayed № 1,2,4,5,6,7,8,9 numbers of images i sent to msql.
But Image diplayed nothing.
I need help in this.
If there is error in my code someone to correct Me.
Thankx.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,833
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 344
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to view image in Msql

 
0
  #2
Apr 4th, 2008
You can't view an image from mysql console.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 238
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 5
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: how to view image in Msql

 
0
  #3
Apr 4th, 2008
yes,i there a posilibility i can see the image there???.
when i upload image they just name numbers and i cand see what i sent.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,833
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 344
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to view image in Msql

 
0
  #4
Apr 4th, 2008
You can't see the image. You need to write a php script to see the image.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 238
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 5
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: how to view image in Msql

 
0
  #5
Apr 4th, 2008
lets make it simple this down is the script i used to upload photos.
image.php

  1. <?php
  2. //connect to database server
  3. $dbcnx=@mysql_connect('localhost','root','******');
  4. if (!$dbcnx){
  5. exit('<p>Unable to connect to the database<p>');
  6. }
  7.  
  8. //select the joke database
  9. if (!@mysql_select_db('zedekia')) {
  10. exit('<p>unable to locate the register' .
  11. 'database at this time.<p>');
  12. }
  13.  
  14. // Make sure the user actually
  15. // selected and uploaded a file
  16. if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
  17.  
  18. // Temporary file name stored on the server
  19. $tmpName = $_FILES['image']['tmp_name'];
  20.  
  21. // Read the file
  22. $fp = fopen($tmpName, 'r');
  23. $data = fread($fp, filesize($tmpName));
  24. $data = addslashes($content);
  25. fclose($fp);
  26.  
  27.  
  28. // Create the query and insert
  29. // into database.
  30. $query = "INSERT INTO image ";
  31. $query = "(image) VALUES ('$data')";
  32. $results = mysql_query($query);
  33.  
  34. // Print results
  35. print "Thank you, your file has been uploaded.";
  36.  
  37. }
  38. else {
  39. print "No image selected/uploaded";
  40. }
  41.  
  42.  
  43.  
  44. ?>

And i just created this one to view photos.
view.php
  1. <html>
  2. <head>
  3. <title>view images from MSQL</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </head>
  6.  
  7. <body>
  8. <?php
  9. //connect to database server
  10. $dbcnx=@mysql_connect('localhost','root','650715');
  11. if (!$dbcnx){
  12. exit('<p>Unable to connect to the database<p>');
  13. }
  14.  
  15. //select the joke database
  16. if (!@mysql_select_db('zedekia')) {
  17. exit('<p>unable to locate the register' .
  18. 'database at this time.<p>');
  19. }
  20.  
  21. $query = "SELECT *FROM image ";
  22. $result = mysql_query($query) or die('Error, query failed');
  23.  
  24. while($row=mysql_fetch_array($result)){
  25.  
  26. echo '<image src="'.$row['image'].'" width=50 height=80>';
  27. }
  28. ?>
  29. </body>
  30. </html>
But it just shows the boundaries of the photo
which i put width=50 and height=80 with no image.
I there something wrong with my CODE?
Last edited by peter_budo; Apr 5th, 2008 at 12:21 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,833
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 344
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to view image in Msql

 
0
  #6
Apr 4th, 2008
echo '<image src="'.$row['image'].'" width=50 height=80>';
Thats wrong.
1. Its <img tag.
2. You can't directly give Img src = $row['image'].

Check this or this .
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 238
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 5
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: how to view image in Msql

 
0
  #7
Apr 4th, 2008
i wrote it but i still have the same problem.
Sorr if i`m asking a lot of questions.
According to my code can please write down how i can do it.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 238
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 5
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: how to view image in Msql

 
0
  #8
Apr 11th, 2008
thankx a lot,the links you Gave me hepled to solve my problem,though for the first time it seemed difficult to understand.
Do you have an link for PAGINATION
Tutorial or if you can help me in pagination.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,833
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 344
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to view image in Msql

 
0
  #9
Apr 11th, 2008
Umm.. not really.. sorry ! But, google is your friend
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 238
Reputation: mrcniceguy is an unknown quantity at this point 
Solved Threads: 5
mrcniceguy mrcniceguy is offline Offline
Posting Whiz in Training

Re: how to view image in Msql

 
0
  #10
Apr 11th, 2008
ok
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1387 | Replies: 9
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC