Jump to content

Recommended Posts

You would reverse the process that you used to insert the image NAME into the database.  Your images are not in the database, they are in a folder named "images" that resides in your parent directory where this script is run from.

So, you would need a select query from the database, to get the image names, then display them just like any other image.

 

 

$sql = "SELECT images_path, userID, submission_date FROM images_tbl";
$result = mysql_query($sql) or trigger_error(mysql_error());
if(mysql_num_rows() > 0) {
 while($row = mysql_fetch_assoc($result)) {
   echo '<img src="images/' . $row['images_path'] . '" alt="Image" /><br />';
 }
}

 

Now, this will get you the image from names from the database, and it will display them on a page, BUT do not ever use the code that you have posted.  It is way to simplistic, open to all manners of evil by others.  You will have a compromised database, and maybe even the whole server.  You should be using MySQLi extension or PDO for database interaction.  As well as proper sanitation/validation of all incoming data.  Coupling that with proper escaping of your outgoing data.

Basically, don't just copy paste code off the web, and get an application up and running.  You are responsible for all data transfers from your site, and should take that responsibility with the utmost care.

This guy has a pretty good write up on why your way is bad http://http://nullcandy.com/php-image-upload-security-how-not-to-do-it/

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.