Hi there,
I am writing some website that allows some-one to see thumbnails of an image, after which he/she can click on the image to see the full picture. As I dont want to do parameter passing on the url, I am using session variables to pass parameters.
I have written a small script in PHP4 that retrieves data from a MySQL DataBase, processes it and sends it out. It's almost working as I want it to, but there's one little thing I can't solve.
In the calling script I retrieve some IDs from a table and then start to loop through the pics I want to display
$cSql = "SELECT photoID FROM photos WHERE sessionID = " . $sessID;
$link = mysql_connect("localhost", "UID", "PW");
$QueryRes = mysql_db_query($database, $cSql, $link);
while($row = mysql_fetch_array($QueryRes)) {
$nPicID = $row["photoID"];
if(session_is_registered(nPicID)) {
session_unregister(nPicID);
}
session_register(nPicID);
echo "<img src=\"getthumb.php\"><br>" . $nPicID . "<br>";
} // while
mysql_close($link);
The getthumb.php is as follows:
if($nPicID == "") {
header("Location: sessionselector.php");
} else {
$cSql = "SELECT strFileType, strFileName, blobPhoto FROM photos WHERE photoID = " . $nPicID;
$lnk = mysql_connect("localhost", "UID", "PW");
$QueryRes = mysql_db_query($database, $cSql, $lnk);
$row = mysql_fetch_array($QueryRes);
$data = $row["blobPhoto"];
$type = $row["strFileType"];
$fnam=$row["strFileName"];
mysql_close($lnk);
// todo: resize image
Header("Content-disposition: filename=gekloot");
//header( "Content-Disposition: filename=gekloot");
header("Content-type: " . $type);
print $data;
session_unregister(nPicID);
exit();
} // if2
} // if1
The problem is that on the calling page I get the result of n times the first image in the DB, all called getthumbs.php.
I think this is because the header info sent by getthumbs.php is disregarded by the calling page as some output was already sent to the browser. The brouwser in its turn, recognises n times the same file and displays it as such.
Does anybody have a workaround???