954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to view image in Msql

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.

mrcniceguy
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 17
Solved Threads: 8
 

You can't view an image from mysql console.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

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.

mrcniceguy
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 17
Solved Threads: 8
 

You can't see the image. You need to write a php script to see the image.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

lets make it simple this down is the script i used to upload photos.
image.php

<?php
//connect to database server
$dbcnx=@mysql_connect('localhost','root','******');
if (!$dbcnx){
exit('<p>Unable to connect to the database<p>');
}

//select the joke database
if (!@mysql_select_db('zedekia')) {
exit('<p>unable to locate the register' .
   'database at this time.<p>');
}

// Make sure the user actually 
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

      // Temporary file name stored on the server
      $tmpName  = $_FILES['image']['tmp_name'];  
       
      // Read the file 
      $fp      = fopen($tmpName, 'r');
      $data = fread($fp, filesize($tmpName));
      $data = addslashes($content);
      fclose($fp);
      

      // Create the query and insert
      // into  database.
      $query = "INSERT INTO image ";
      $query = "(image) VALUES ('$data')";
      $results = mysql_query($query);
      
      // Print results
      print "Thank you, your file has been uploaded.";
      
}
else {
   print "No image selected/uploaded";
}



?>


And i just created this one to view photos.view.php

<html>
<head>
<title>view images from MSQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
//connect to database server
$dbcnx=@mysql_connect('localhost','root','650715');
if (!$dbcnx){
exit('<p>Unable to connect to the database<p>');
}

//select the joke database
if (!@mysql_select_db('zedekia')) {  
exit('<p>unable to locate the register' .
   'database at this time.<p>');
}

$query = "SELECT  *FROM image ";
$result = mysql_query($query) or die('Error, query failed');

    while($row=mysql_fetch_array($result)){
	
	echo '<image src="'.$row['image'].'" width=50 height=80>';
	}
?>
</body>
</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?

mrcniceguy
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 17
Solved Threads: 8
 
echo '';

Thats wrong. 1. Its $row['image']. this or this .

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

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.

mrcniceguy
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 17
Solved Threads: 8
 

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.

mrcniceguy
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 17
Solved Threads: 8
 

Umm.. not really.. sorry ! But, google is your friend :)

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 
mrcniceguy
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 17
Solved Threads: 8
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You