in reply to foreach and lists

BTW, if you are already using prepare, use it with placeholders:
$query = $dbh->prepare('INSERT INTO products_attributes (products_id, +options_id, options_values_id, options_values_price, price_prefix, pr +oducts_options_sort_order) VALUES (?, ?, ?, ?, ?, ?)'); $query->execute($products_id, $options_id, $options_values_id, $option +s_values_price, $price_prefix, $products_options_sort_order) or exit +1;
See Exploits of a Mom.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: foreach and lists
by hippo (Archbishop) on Mar 14, 2013 at 12:35 UTC

    And of course once you have done that you will be able to move the prepare outside the loop while keeping the execute inside the loop. This is where a lot of the efficiency of prepared statement handles comes in.

    $query = $dbh->prepare('INSERT INTO products_attributes (products_id, +options_id, options_values_id, options_values_price, price_prefix, pr +oducts_options_sort_order) VALUES (?, ?, ?, ?, ?, ?)'); foreach $line (@nametape) { .... $query->execute($products_id, $options_id, $options_values_id, $op +tions_values_price, $price_prefix, $products_options_sort_order) or e +xit 1; }

    Think about other things such as the assignment of $options_id which could be moved outside the loop as well.

      Thank you everyone for your help, I now have my script working.