Not sure but I would try changing the query:

        my $sth = $dbh->prepare("
                SELECT id from session
                WHERE field = ?
                ");
          $sth->bind_param( 1, $SessionID );
        $sth->execute;

That might help.
        


-----Original Message-----
From: Jason Wilkes [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 04, 2002 11:46 AM
To: [EMAIL PROTECTED]
Subject: Understanding why this "fixes" my perlaccess script


Hi folks,

I use the following modperl script to control page
access, based on a sessionid held in a cookie. A
database is queried to get the user id from the db
based on the cookie value. (No cookie, and your
bounced to the logon screen).

So far so good, and all works well. Except for one
user id (actually id=333), which causes an "internal
server error". If I put print debugging lines in -
everything works (even for user 333). If I take them
out again all other users work fine except 333.
Can anybody throw any light on this??

BTW: when the "internal server error" happens there is
no log of it in the error_log - although the HTTP
response code in access_log is 333 (which I don't
think is a valid response code).

Any thoughts would be much appreciated.

The code is: -

package My::Package;

use strict;
use Apache::Constants qw(:common);
use CGI::Cookie;
use DBI;

sub handler {

open (DBG, ">>/tmp/debug.txt"); # DEBUG LINE

my $r = shift;
my %cookies =
CGI::Cookie->parse($r->header_in('Cookie'));
return (FORBIDDEN) unless $cookies{'SessionID'};

my $SessionID = $cookies{'SessionID'}->value;

...
stuff to set up the DBI connection
...

        my $sth = $dbh->prepare("
                SELECT id from session
                WHERE field = '$SessionID'
                ");
        $sth->execute;
        my $answer = $sth->fetchrow;

print DBG "The id is $answer\n"; # DEBUG LINE

        $sth->finish;
        $dbh->disconnect;

        return (FORBIDDEN) unless $answer;
        
close (DBG);

}

1;
__END__







__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Reply via email to