in reply to Multpile checkbox handling?

Hi, it's me again ;-) I'm using the following code to get the input:
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $input{$name} = $value; }
The Problem is, my script above writes simply nothing into the database. Anybody has an idea, what I'm doing wrong? Thanks again GG

Replies are listed 'Best First'.
Re: Re: Multpile checkbox handling?
by eejack (Hermit) on Apr 16, 2001 at 09:11 UTC
    You are not printing this data to your database, you are just printing, except in the one line where you print to DAT....

    Also, if I am reading it correctly, you are going through all of your values in the hash input 16 times. It looks like your routine will assign a value of either three dashes or the last value of $name from the part of your script that deals with inputting. This will probably clobber all of your work of assigning these values.

    You might want to try this in your script to see what the values are...

    foreach $key (keys (%input)) { print qq|The key is $key and the value is $input{$key}\n|; }
    To see what effect your loop has on the data, try running it above and below where you trying to write to the database. I often do this to doublecheck I am not messing up my values (which I do with amazing frequency).

    I still recommend CGI.pm BTW - makes lots of things a bit easier.

    HTH,

    Kind thanks to Beatnik on his gentle clarification of the real value of $ENV{'CONTENT_LENGTH'}
    EEjack