PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
iG9
Forum Commoner
Posts: 38 Joined: Fri Jul 18, 2008 2:11 pm
Post
by iG9 » Mon Aug 17, 2009 6:42 am
Here's the way I'm displaying some images. All images with a common attribute get displayed in a table with proplist.php. If you click one of them it opens full size. The image is generated by viewprop.php. It works in ff, but ie doesn't know what to do with the image link and asks if you want to save it or find a program online to open it. Here's the code:
proplist.php
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Luxury Maui Property</title>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js'></script>
<script type='text/javascript' src='js/lightview.js'></script>
<link rel="stylesheet" href="css/lightview.css" type="text/css" media="screen" title="no title" charset="utf-8" />
</head>
<body>
<?php
include '../lmp_includes/lmp_utilities.php';
$db = db_connect();
if ($_GET['mls']) {
$mls = mysql_real_escape_string($_GET['mls']); //these five get the propID
$q = "select propID from properties where mls = $mls";
$r = mysql_query($q);
$d = mysql_fetch_object($r);
$id = $d->propID;
$q = "select * from images where propID = $id"; //these three lines get num rows
$r = mysql_query($q);
$numImages = mysql_num_rows($r);
$d = mysql_fetch_assoc($r);
echo "<table><td>";
for ($i = 0; $i < $numImages; $i++) {
if (($i!=0) && !($i%4)) {
echo "</td><tr></tr><td>";
}
echo "<a href=\"viewprop.php?mls=$mls&offset=$i\"><img src=\"viewprop.php?mls=$mls&offset=$i\" height=\"150px\" width=\"200px\"/></a>";
}
echo "</td></table>";
} else {
echo "I need an ID.";
}
?>
</body>
</html>
viewprop.php
Code: Select all
<?php
include '../lmp_includes/lmp_utilities.php';
$db = db_connect();
if ($_GET['mls'] || $_GET['offset']) {
$mls = mysql_real_escape_string($_GET['mls']);
$offset = mysql_real_escape_string($_GET['offset']);
$q = "select propID from properties where mls = $mls";
$r = mysql_query($q);
$d = mysql_fetch_object($r);
$id = $d->propID;
header('Content-type: image/jpg');
$q = "select * from images where propID = $id limit $offset, 1";
$r = mysql_query($q);
$d = mysql_fetch_object($r);
echo $d->image;
} else {
echo "I need both an mls and an offset.";
}
?>
Any help is greatly appreciated.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Mon Aug 17, 2009 7:26 am
I don't think IE understand image/jpg as a content type. It has to image/pjpeg I believe. (don't ask me why)
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Mon Aug 17, 2009 11:32 am
Try the following...
Code: Select all
<?php echo $_SERVER['HTTP_ACCEPT'];?>
I use the following file for local testing for quick reference...
Code: Select all
<?php
echo '<div>'.$_SERVER['PHP_SELF'].'</div>';
echo '<div>'.$_SERVER['argv'].'</div>';
echo '<div>'.$_SERVER['argc'].'</div>';
echo '<div>'.$_SERVER['GATEWAY_INTERFACE'].'</div>';
echo '<div>'.$_SERVER['SERVER_ADDR'].'</div>';
echo '<div>'.$_SERVER['SERVER_NAME'].'</div>';
echo '<div>'.$_SERVER['SERVER_SOFTWARE'].'</div>';
echo '<div>'.$_SERVER['SERVER_PROTOCOL'].'</div>';
echo '<div>'.$_SERVER['REQUEST_METHOD'].'</div>';
echo '<div>'.$_SERVER['REQUEST_TIME'].'</div>';
echo '<div>'.$_SERVER['QUERY_STRING'].'</div>';
echo '<div>'.$_SERVER['DOCUMENT_ROOT'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT_CHARSET'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT_ENCODING'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT_LANGUAGE'].'</div>';
echo '<div>'.$_SERVER['HTTP_CONNECTION'].'</div>';
echo '<div>'.$_SERVER['HTTP_HOST'].'</div>';
echo '<div>'.$_SERVER['HTTP_REFERER'].'</div>';
echo '<div>'.$_SERVER['HTTP_USER_AGENT'].'</div>';
echo '<div>'.$_SERVER['HTTPS'].'</div>';
echo '<div>'.$_SERVER['REMOTE_ADDR'].'</div>';
echo '<div>'.$_SERVER['REMOTE_HOST'].'</div>';
echo '<div>'.$_SERVER['REMOTE_PORT'].'</div>';
echo '<div>'.$_SERVER['SCRIPT_FILENAME'].'</div>';
echo '<div>'.$_SERVER['SERVER_ADMIN'].'</div>';
echo '<div>'.$_SERVER['SERVER_PORT'].'</div>';
echo '<div>'.$_SERVER['SERVER_SIGNATURE'].'</div>';
echo '<div>'.$_SERVER['PATH_TRANSLATED'].'</div>';
echo '<div>'.$_SERVER['SCRIPT_NAME'].'</div>';
echo '<div>'.$_SERVER['REQUEST_URI'].'</div>';
echo '<div>'.$_SERVER['PHP_AUTH_DIGEST'].'</div>';
echo '<div>'.$_SERVER['PHP_AUTH_USER'].'</div>';
echo '<div>'.$_SERVER['PHP_AUTH_PW'].'</div>';
echo '<div>'.$_SERVER['AUTH_TYPE'].'</div>';
?>
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Mon Aug 17, 2009 11:35 am
But IE sends */* as its accept header, when it obviously supports nowhere near everything.
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Mon Aug 17, 2009 11:39 am
IE7...
*/*
IE8...
image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, application/x-shockwave-flash, */*
iG9
Forum Commoner
Posts: 38 Joined: Fri Jul 18, 2008 2:11 pm
Post
by iG9 » Mon Aug 17, 2009 3:40 pm
Thanks for the help everybody. jackpf, that worked. =)
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Mon Aug 17, 2009 3:53 pm
Cool.
That's weird though, because IE8 says it accepts image/jpeg and image/pjpeg.
Maybe it was just because you used jpg...maybe it has to be jpeg?
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Mon Aug 17, 2009 4:06 pm
The only time I've ever encounter mime issues (besides IE and application/xhtml+xml) is when I pay attention to Safari's error console; I've never seen the other browsers have any issues (spit out errors/warnings) and Ie will simply give you the save file prompt.
Try commenting out the header on line 13 and see if it functions correctly, it may be an unnecessary step.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Mon Aug 17, 2009 6:10 pm
I doubt that would work. Apache would send the default header for php, whatever that is. So you'll just see a load of binary or something.