Maybe someone can help with the odd problem. I have a small program which gets a random image (a photo) from the database, then presents it to the screen. The script is called up as though it were am image using an img src tag.
It works fine but I am having trouble passing on the height and width values to the screen. The pairs seem to be one image behind the one being shown on the screen so, unless the same image happens to load a second time in a row, the aspect ratio is off.
In order to try to add some slight delay for the writing of the session for the specific image being viewed, I added a second "select" but it made no difference at all.
Any ideas? These two pieces of code are using a couple custom functions (one for the session values and the other for the database connections), but these work fine and are not part of the problem - at least I don't think they are because they are working.
Don
contact@pc-homepage.com
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
It works fine but I am having trouble passing on the height and width values to the screen. The pairs seem to be one image behind the one being shown on the screen so, unless the same image happens to load a second time in a row, the aspect ratio is off.
Code:
SetSession("ImageWidth", "");
SetSession("ImageHeight", "");
$DB->query("SELECT Image, ImageFormat, ImageWidth, ImageHeight FROM images_random WHERE Image IS NOT NULL AND RandomType = 3 ORDER BY RAND() LIMIT 1", $DB);
if ($DB->next_record()) {
$mime_type = $DB->f("ImageFormat");
$Image = $DB->f("Image");
SetSession("ImageWidth", $DB->f("ImageWidth"));
SetSession("ImageHeight", $DB->f("ImageHeight"));
}
if ($DB->next_record()) {
$Image = $DB->f("Image");
}
Header ("Content-type: image/" . $mime_type);
Header ("Pragma: no-cache");
echo $Image;
exit();
In order to try to add some slight delay for the writing of the session for the specific image being viewed, I added a second "select" but it made no difference at all.
Code:
SetSession("ImageWidth", "");
SetSession("ImageHeight", "");
$DB->query("SELECT ID, ImageFormat, ImageWidth, ImageHeight FROM images_random WHERE Image IS NOT NULL AND RandomType = ".$Type . " ORDER BY RAND() LIMIT 1", $DB);
if ($DB->next_record()) {
$image_id = $DB->f("ID");
$mime_type = $DB->f("ImageFormat");
SetSession("ImageWidth", $DB->f("ImageWidth"));
SetSession("ImageHeight", $DB->f("ImageHeight"));
}
$DB->query("SELECT Image FROM images_random WHERE ID = ".$image_id);
if ($DB->next_record()) {
$Image = $DB->f("Image");
}
Header ("Content-type: image/" . $mime_type);
Header ("Pragma: no-cache");
echo $Image;
exit();
Any ideas? These two pieces of code are using a couple custom functions (one for the session values and the other for the database connections), but these work fine and are not part of the problem - at least I don't think they are because they are working.
Don
contact@pc-homepage.com
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases