Page 1 of 1

Images showing up in code

Posted: Mon Feb 01, 2010 3:33 pm
by Jfavelle
Hi

My images aren't loading, instead i am just getting them displayed as code like this:

Code: Select all

 
ÿØÿà\0JFIF\0::\0\0ÿáPExif\0\0II*\0\0\0\0\0\0 \0\0\0n\0\0\0\0\0\0\0Ž\0\0\0\0 \0\0\0¦\0\0\01\0 \0\0\0²\0\0\02\0\0\0\0Ò\0\0\0\0\0\0\0\0\0\0i‡\0\0\0\0\0\0¥Ä\0"\0\0æ\0\0\0\0\0\0\0OLYMPUS DIGITAL CAMERA \0OLYMPUS IMAGING CORP. \0FE210,X775\01.0 \02009:09:16 16:56:26\0PrintIM\00300\0\0%\0\0\0\0\0\0\0\0\0î\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0 \0\0\0\0\0 \06\0\0 \0\0\0\0\0 \0\0\0\0\0\0N\0\0\0r\0\0 \0Æ\0\0\0\0\0\0ÿ\0\0\0ƒ\0\0\0ƒ\0\0\0ƒ\0\0\0ƒ\0\0\0ƒ\0\0\0€€€\0€\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0 \0\0\0\0 è\0\0 \0\0\0\0 \0\0\0\0\0\0\0ÿ\0\0\0ƒ\0\0\0ƒ\0\0\0ƒ\0\0\0€\0\0\0\0\0\0\0\0 \0\0''\0\0 \0\0''\0\0—\0\0''\0\0°\0\0''\0\0\0\0''\0\0^\0\0''\0\0‹\0\0\0''\0\0Ë\0\0''\0\0å\0\0''\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0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\0Z\0\0\0> \0\0\0(\0Ž\0\0˜ \0\0\0)\0~\0\0\0& \0\0\0\0\0\01.005\0\0\0\0\0\0\0\0\0\0\0\0\0d\0\0\0d\0\0\0ú\0\0è\0\0¨ÿáþ|þ¥ÿÚþtþD4334\0OLYMPUS DIGITAL CAMERA \0\0\0\0 \0\0\06\0\0\0\0\0\0OK\0\0\0\0\0\0OK\0\0\0\0\0\0OK\0\0\0\0\0\0OK\0\0\0\0\0\0OK\0\0\0\0\0\0OK\0\0\0\0\0\0OK\0\0
Help me:)

Re: Images showing up in code

Posted: Mon Feb 01, 2010 4:02 pm
by social_experiment
Please paste the code that you are using

Re: Images showing up in code

Posted: Tue Feb 02, 2010 9:25 am
by Jfavelle
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Here is the code that selects the image from the db:

Code: Select all

<?php
     // some basic sanity checks
     if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
         //connect to the db
         $link = mysql_connect("localhost", "", "") or die("Could not connect: " . mysql_error());
  
         // select our database
         mysql_select_db("people") or die(mysql_error());
           
           // get the image from the db
        $sql = "SELECT Picture FROM people WHERE ID=" . $_GET['image_id'];
        
         // the result of the query
         $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
  
         // set the header for the image
         header("Content-type: image/jpeg");
                  echo mysql_result($result, 0);
  
        // close the db link
         mysql_close($link);
     }
     else {
         echo 'Please use a real id number';
     }
 ?>
And this is the code that displays it

Code: Select all

$fldPicture = $db->f("r_Picture");
 
if(strlen($fldPicture))
      {
        $tpl->set_var("Image", "<img style='float:right' width='80px' height='80px' src='image.php?image_id=" . $fldID_ID . "' alt='Photo' />");
      }
      else
      {
        $tpl->set_var("Image", "");
 
Thanks Greatly!


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Images showing up in code

Posted: Tue Feb 02, 2010 9:55 am
by pickle
Is that code you posted in the original post the source code from the entire page? What's happening is the browser isn't realizing how to display the data it's receiving. That happens because the headers sent don't match the data. I see you're sending the Content-type header, but there must be other headers being sent earlier. Do you have any spaces at the beginning of the file, or in any included files?

Re: Images showing up in code

Posted: Tue Feb 02, 2010 10:33 am
by Jfavelle
The code I am getting in the original post is what when i go to the img src from the image tag: i.e image.php?image_id=181. I have a file which imports from that php and the headers I have in that are

Code: Select all

//-------------------------------
// Verify user's security level and redirect to login page if needed
//-------------------------------
 
function check_security($security_level)
{
  global $PeopleRights;
  if(!session_is_registered("PeopleID"))
  {
    header("Location: refLogin.php?querystring=" . urlencode(getenv("QUERY_STRING")) . "&ret_page=" . urlencode(getenv("PATH_INFO")));
    exit;
  }
  else
    if(!session_is_registered("PeopleRights") || $PeopleRights < $security_level)
    {
      header("Location: screeningLogin.php?querystring=" . urlencode(getenv("QUERY_STRING")) . "&ret_page=" . urlencode(getenv("PATH_INFO")));
      exit;
    }
}
But that shouldn't conflict with the image should it?

Re: Images showing up in code

Posted: Tue Feb 02, 2010 10:36 am
by pickle
So the source code of the page is something like:

Code: Select all

<img src = "ÿØÿà\0JFIF\0 etc..." />
??

Re: Images showing up in code

Posted: Tue Feb 02, 2010 10:47 am
by Jfavelle
No, sorry when I went to http://westnet/intranet/people/image.php?image_id=181, that was what was displaying in the browser. I just went there again and it is now

<img src="http://westnet/intranet/people/image.php?image_id=181" />

... don't ask me.

The image still isn't displaying though, I am saving it to the data base as a blob could that possibly have anything to do with it.

Thanks so much!

Re: Images showing up in code

Posted: Tue Feb 02, 2010 2:19 pm
by pickle
Possibly. If the image is larger than 64K, it won't fit in a BLOB & would be truncated. That might be what you're seeing.

If you've got Firefox, install Firebug & go to: http://westnet/intranet/people/image.php?image_id=181 . I think Firebug gives you a chance to see the headers that are sent.

Re: Images showing up in code

Posted: Thu Feb 04, 2010 11:35 am
by Jfavelle
the images are smaller then 64 k, it doesn't matter. The header is showing up as well.

Please, I need you guys don't let me down!

Re: Images showing up in code

Posted: Thu Feb 04, 2010 12:26 pm
by AbraCadaver
Try:

Code: Select all

echo stripslashes(mysql_result($result, 0));