RandomWalk has asked for the wisdom of the Perl Monks concerning the following question:
The context is a mod_perl Apache http server and DBI access to mysql.
The action of an html form is a perl handler. The handler starts off by getting the request object and reading an identifying cookie:
The handler takes arguments from $r->param and writes them to a mysql table by means of a database handle obtained from DBI->connect.sub handler { my $r = Apache2::Request->new(shift); my %in_cookies = Apache2::Cookie->fetch ($r); my $session = $in_cookies{"ID"} && $in_cookies{"ID"}->value; ...
The problem: it has occurred at least once that data from one call to the handler has persisted to the next and has been written to a record belonging to a different session. Specifically, this section of code misfired, the hash %ship_address somehow retaining data from its previous assignment:
The 2nd customer was very surprised to learn he lived on the 5th floor of a one story house...while ( my ($key,$value) = each %ship_address ) { $dbh->do("update bill set ship$key = ? where session = ?", undef, $ +value, $session);
I am uncertain how to isolate the problem. Can you help? Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: keeping variables separate
by almut (Canon) on Apr 20, 2009 at 16:08 UTC | |
by RandomWalk (Beadle) on Apr 20, 2009 at 17:41 UTC | |
by almut (Canon) on Apr 20, 2009 at 18:02 UTC | |
by RandomWalk (Beadle) on Apr 20, 2009 at 18:50 UTC | |
by almut (Canon) on Apr 20, 2009 at 20:11 UTC | |
|
Re: keeping variables separate
by kennethk (Abbot) on Apr 20, 2009 at 15:38 UTC |