| | |
how to view image in Msql
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 238
Reputation:
Solved Threads: 5
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.
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.
•
•
Join Date: Mar 2008
Posts: 238
Reputation:
Solved Threads: 5
lets make it simple this down is the script i used to upload photos.
image.php
And i just created this one to view photos.
view.php
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?
image.php
php Syntax (Toggle Plain Text)
<?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
php Syntax (Toggle Plain Text)
<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>
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
![]() |
Other Threads in the PHP Forum
- Previous Thread: Code only inserts last value in array into the database
- Next Thread: Mysql with php (booked room)
Views: 1387 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api archive array auto box buttons cakephp cart check checkbox class classes cms code combobox database date development directory display download dropdown dropdownlist drupal dynamic echo email error file files form forms functions header href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu mlm mod_rewrite multiple mysql order output parse password paypal php problem query radio random recursion redirect regex remote rows script search select server session sort source sql string structure syntax table update upload url user validation variable video web website wordpress xml zend






