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.

Recommended Answers

All 9 Replies

You can't view an image from mysql console.

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.

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

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?

echo '<image src="'.$row.'" width=50 height=80>';

Thats wrong.
1. Its <img tag.
2. You can't directly give Img src = $row.

Check this or this .

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.

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.

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

ok

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.