List:General Discussion« Previous MessageNext Message »
From:Richard Reina Date:July 13 2000 11:40pm
Subject:problem with insert SET data type
View as plain text  
I have written a small script that collects data from a user input
screen organizes it into an array  named @values and inserts it into a
mysql table.  Everything works great except the data in @D_zone that I
save as $values[9] = "@D_zone" which is to be inserted into the tables
SET field.   The data seems to be stored fine in the array.  However, it
never makes it into the table with all of the other data.

#this piece collects data that goes into an enum file (works fine)

if ($ENTERED[0] eq "Y") {
        $values[10] = '53 Van';
        endif;
} elsif ($ENTERED[1] eq "Y") {
             $values[10] = '48 Van';
             endif;
        } elsif ($ENTERED[2] eq "Y") {
                     $values[10] = '48 Reefer';
                      endif;
                } elsif ($ENTERED[3] eq "Y") {
                             $values[10] = '53 Reefer';
                             endif;
                        } elsif ($ENTERED[4] eq "Y") {
                                    $values[10] = '24 Straight Truck';
                                    endif;
                                } elsif ($ENTERED[5] eq "Y") {
                                             $values[10] = '48 Flatbed';

                                             endif;
                                        }
#putting more values into @values. No Problem.

$values[0] = $ENTERED[6];
$values[1] = $ENTERED[7];
$values[2] = $ENTERED[26];
$values[3] = $ENTERED[24];
$values[4] = $ENTERED[25];
$values[5] = 0;
$values[6] = $ENTERED[22];
$values[7] = $ENTERED[9];
$values[8] = $ENTERED[10];

# collecting the datd that is supposed to go into SET field called
dest_zone (in mysql table)

if ($ENTERED[12] eq "Y") {
         push(@D_zone, 'Z0');
}
if ($ENTERED[13] eq "Y") {
         push(@D_zone, 'Z1');
}
if ($ENTERED[14] eq "Y") {
         push(@D_zone, 'Z2');
}
if ($ENTERED[15] eq "Y") {
         push(@D_zone, 'Z3');
}
if ($ENTERED[16] eq "Y") {
         push(@D_zone, 'Z4');
}
if ($ENTERED[17] eq "Y") {
         push(@D_zone, 'Z5');
}
if ($ENTERED[18] eq "Y") {
         push(@D_zone, 'Z6');
}
if ($ENTERED[19] eq "Y") {
         push(@D_zone, 'Z7');
}
if ($ENTERED[20] eq "Y") {
         push(@D_zone, 'Z8');

if ($ENTERED[21] eq "Y") {
         push(@D_zone, 'Z9');
}

#putting more values into @values.

$values[9] = "@D_zone";
$values[11] = $ENTERED[23];

#this piece displays what was entered into @values, and the set field
looks fine (sample output: Z1 Z4 Z8)
  &top_title("Registration Demo");
  if (&menu_getexit() eq "\cX") {       # Check for aborted data entry
    &print_nl("(Data entry was aborted by Control-X)",2);
  } else {
    &print_nl("Here is what was returned in \@values:",2);
    for ($j = 0; $j <= $#values; $j++) {
      &print_nl("\$values[$j]: $values[$j]",1);
    }
  }
  &pause("");



use DBI;
my $dbh = DBI->connect("DBI:mysql:inventory","root","rr5492");
my $q = "INSERT INTO avlb_trucks VALUES (" . (join ",", split /,/, ("?,"
x
@values)) . ")";
my $sth = $dbh->prepare($q);
$sth->execute(@values);
$dbh->disconnect;


In the end everything goes into the table perfect except that data which
is to go into the SET field.  I've tried everything I can think of, any
help would be greatly appreciated.

Richard

Thread
problem with insert SET data typeRichard Reina14 Jul