Wes,

Thanks for your quick reply.  I understand the relationships enough to
know that my original subject line was confusing.  I can eliminate the
parse_form subroutine, but it doesn't really make a difference, the form
input isn't recognized. The problems show up in my original html print
statement 
        print <<"XXXX";
        <HTML>
        <HEAD>etc
 which doesn't initialize, tho the HTML HEAD etc prints out when I
execute the script.  
Then this subroutine doesn't execute:
        
        if ($self{'lookup'} ne "") {
            &display_acronym; }

I changed the name of the variable that associates names with values
from $in (my parse_form subroutine) to $self, because that is what
CGI.pm uses.  I get the same results as before.   Assuming that I'm
calling the CGI.pm correctly, the error must be at $self{'lookup'} (or
$in{'lookup'}), the reference to my form input.

I'm using Postgres 7.1, and I don't think that loading a more recent
version will fix this problem.  Help!

Christine

[EMAIL PROTECTED] wrote:
> 
> First of all, parsing form input has nothing to do with the database.  Think of
> three separate pieces of the application: the database, the client web browser,
> and the web server including your perl/cgi script.  Your perl script talks to
> the database, and it talks to the web browser.  It's ability to talk to the one
> doesn't affect its ability to talk to the other, except that it might not have
> valid data to give to B if it can't talk to A.
> 
> Secondly, you shouldn't have to write your own parse_form routine.  This is
> provided for free by lots of modules, including CGI.pm, which you're already
> using.  Take advantage of it; it's already been debugged, is in wide use, and
> will make your life easier.  Me, I use mod_perl and HTML::Mason
> (www.masonhq.com).
> 
> Finally, the latest version of Postgresql is 7.1.3, and has lots of bug fixes
> and performance improvements over 7.0.  7.2 will be out within a few months as
> well; you might consider upgrading if you ever have time.
> 
> Hope this helps.  Good luck!
> 
> -- Wes Sheldahl
> 
> "Christine Kluka" <[EMAIL PROTECTED]> on 08/22/2001
> 10:06:40 AM
> 
> To:   "Perl DBI" <[EMAIL PROTECTED]>
> cc:    (bcc: Wesley Sheldahl/Lex/Lexmark)
> Subject:  Parsing forms with DBI
> 
> Hi,
> 
> My perl/cgi script allows me to fetch any row(s) from my Postgres 7.1
> database and display the returns in a Web page as long as I don't have
> to parse name/value input from my HTML form.  When I try to get the
> script to read text input from the form and output the matching row(s)
> to the Web page, the script returns "uninitialized value" errors.
> 
> I copied the parse_form subroutine below.  I start the script with this:
> package DBD::Pg;
> use CGI qw(:standard);
> use DBI;
> use strict;
> 
> Using Postgres 7.0 with the Postgres.pm interface, all subroutines
> executed.  I've changed the script to declare all my variables to comply
> with the "use strict" syntax, including  "my" instead of "local" for
> (%in) = &parse_form.  Is there something different about parsing form
> input with DBD-Pg-1.00?
> 
> TIA,
> 
> Christine
> 
> p.s. The parse_form subroutine is:
> sub parse_form {
> 
>      my (@pairs, %in);
>      my ($buffer, $pair, $name, $value);
> 
>      if ($ENV{'REQUEST_METHOD'} eq 'GET') {
>           @pairs = split(/&/, $ENV{'QUERY_STRING'});
>      }
>      elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
>           read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>           @pairs = split(/&/, $buffer);
>      }
>      else {
>      }
>      PAIR: foreach $pair (@pairs) {
>           ($name, $value) = split(/=/, $pair);
> 
>           $name =~ tr/+/ /;
>           $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> 
>           $value =~ tr/+/ /;
>           $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> 
>           #$value =~ tr/a-z/A-Z/;
> 
>           $value =~ s/<!--(.|\n)*-->//g;
>                 # Remove SSI.
>           if ($value eq "---") { next PAIR; }
> 
>                 # This is used as a default choice for select lists
>                 # and is ignored.
>           (exists $in{$name}) ?
>                ($in{$name} .= "~~$value") :
>                 # If we have multiple select, then we tack on
>                ($in{$name}  = $value);
>                 # using the ~~ as a seperator.
>      }
>      return %in;
> }

Reply via email to