in reply to Re^2: Process Text File and Write to Database
in thread Process Text File and Write to Database
open INPUT,'<',$out_file or die "Can't open file " . $out_file . "\n$! +\n"; #Open for read while (<INPUT>) { my $name = $connect->quote($_); my $address1 = $connect->quote(<INPUT>); my $address2 = $connect->quote(<INPUT>); my $phone = $connect->quote(<INPUT>); for (<INPUT>) { next if /(Council|^Continuing|^Mapping)/; last; } my $overall = $connect->quote($_); my $inspections = $connect->quote(<INPUT>); my $staffing = $connect->quote(<INPUT>); my $quality = $connect->quote(<INPUT>); my $programs = $connect->quote(<INPUT>); my $beds = $connect->quote(<INPUT>); my $ownership = $connect->quote(<INPUT>); my $query_string = "INSERT INTO nursing_homes (name, address1, + address2, phone, overall, inspections, staffing, quality, programs, +beds, ownership) VALUES ($name, $address1, $address2, $phone, $overal +l, $inspections, $staffing, $quality, $programs, $beds, $ownership)"; #printVariables($name, $address1, $address2, $phone, $overall, + $inspections, $staffing, $quality, $programs, $beds, $ownership, $qu +ery_string); my $query_handle = $connect->prepare("INSERT INTO nursing_home +s (name, address1, address2, phone, overall, inspections, staffing, q +uality, programs, beds, ownership) VALUES ($name, $address1, $address +2, $phone, $overall, $inspections, $staffing, $quality, $programs, $b +eds, $ownership)"); $query_handle->execute(); }
You define $query_string but don't use it, and you're not checking return values for the prepare and execute calls. You must.
|
|---|