Hello,

When I select my images they are opening. Only the jpg will not come in clearly. If you know the code to correct this can you please tell me, Thanks puddin

Here is my code:

<?php
include'db.php';
 // get the variables from home page
   $password = $_SESSION['password'];  
   $email_address = $_SESSION['email_address'];

        $sql_check = mysql_query("SELECT aphoto_filename FROM myd WHERE email_address='$email_address'AND password='$password'");
         $aphoto_filename = mysql_fetch_array($sql_check, MYSQL_BOTH); //MYSQL_BOTH;

         $sql_check_num = mysql_num_rows($sql_check);
         if($sql_check_num == 0){ 


         echo ("You do not have a photo uploaded, please upload a photo");
       } else {
         echo "<img src='".$images_dir."/".$aphoto_filename['aphoto_filename']."'>" ;
}
?>
</p>

It brings in gif photos perfect, but not jpg's!

Edited 3 Years Ago by pyTony: fixed formatting

try looking at the html source of your page and see if the img src is being rendered correctly.
That is, copy whats in between the src attribute, and see if the url actually points to the image.

It may be that the jpgs are named differently in the database, and different in the filesystem, since JPG has many formats. Also windows sometimes adds JPEG as the extension instead of JPG. eg: image.jpg vs image.jpeg.

The other thing is that url's are case sensitive. Your JPGs may be saved as image.JPG and referenced in the db as image.jpg.

I've noticed before that windows uses Caps for JPG file extensions most the time, if not by default.

So the problem is most likely not in your script rendering the html. But in the different names in the database and filesystem.
What you should do is make sure the script that uploads the files, uses a single naming convension, or saves the correct names.

Example:
Your script could save all JPGs as .jpg, so that in the database they will be referenced as .jpg correctly, no matter if the file has the extension JPEG, or jpeg, or jpg or JPG etc.

checking if the file exists via php:
You can also use the file_exists function, to make sure the file exists. (this is a filesytem function, so it wont work with urls, but instead the files location in the directory only... i believe.)
However, you can use fopen() which has a http wrapper (if enabled), so that you can open the url, and just read the headers to see if it supplied a 404 header or not. (404 means the file does not exist).

This question has already been answered. Start a new discussion instead.