Forum Moderators: coopster & phranque

Message Too Old, No Replies

Problem with #include virtual -parameters

#include virtual -problem

         

Zamiboy

12:50 am on Oct 13, 2003 (gmt 0)

10+ Year Member



I have a CGI-script written with perl. It takes only one parameter, category, and returns a table of image thumbnails, selected by category.
It seems to work just fine if i'm posting category-parameter from html form. But, if i'm using #include virtual from html file, it won't work like i want. <!--#include virtual="cgi-bin/showthumbs.cgi?category=flowers" -->
It might work on a first try but if i'm doing the same from another html -file where category is "trees", it still return thumbs of flowers? Like parameter from first try would stay somewhere in buffer? Something wrong with my code?

HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
SERVER_SIGNATURE=<ADDRESS>Apache/1.3.27 Server at localhost Port 80</ADDRESS>
SERVER_SOFTWARE=Apache/1.3.27 (Win32) PHP/4.2.3 mod_perl/1.27_01-dev

Perl-code:

#!C:/phpdev/Perl/

print "Content-type:text/html\n\n";

my ($value, $name, $pair, $buffer, $FORM, $cat)='';

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

$cat =$FORM{'cat'};

use DBI;

my $dsn = 'DBI:mysql:images:localhost';
my $db_user_name = 'root';
my $db_password = '';
my ($id, $password);
my $dbh = DBI->connect($dsn, $db_user_name, $db_password);

if ($FORM{'cat'} eq '') {
$sth = $dbh->prepare("SELECT turl,gurl FROM featured_images") or dienice ("Can't open table: ",$dbh->errmsg);
}
else {
$sth = $dbh->prepare("SELECT turl,gurl FROM featured_images WHERE category=\"$cat\"") or dienice ("Can't open table: ",$dbh->errmsg);
}
$sth->execute;

print "<center><table border=0><tr>\n";

while (($turl,$gurl)=$sth->fetchrow) {
print "<td><a href=\"$gurl\"><img src=\"$turl\" width=\"95\" height=\"140\"></a></td>\n";
}

print "</tr></table>\n";

$dbh->disconnect;

exit();

sub dienice {
my($msg) = @_;
print "Error\n";
print $msg;
exit;
}

jdMorgan

1:19 am on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Zamiboy,

Welcome to WebmasterWorld [webmasterworld.com]!

Just a question...

Have you tried flushing your browser's cache between requests?

If this clears up the problem, you'll need to add a cache-control header to the server response, or perhaps use "static-looking" URLs to reference the thumbs, and then use mod_rewrite or similar to translate that to a script call. This would allow caching of the various thumbnail-populated pages as if they were separate "real" html pages.

Your comment about "works on the first try" is the reason I'm asking about cache issues. That and the fact that I'm no PERL guru... :)

Jim

Zamiboy

8:29 am on Oct 13, 2003 (gmt 0)

10+ Year Member



I tried, it won't solve the problem. Thanks anyway.