in reply to called with 19 bind variables when 20 are needed, error

param in a list context (as you have it) can return 0 or many parameters. (We've hit this subject here before if you search a bit.)

If you add scalar in front of each param, or do something like this instead, you'll be happier:

$sth->execute(map scalar param($_), qw(cat itemid price des longdes si +ze o1n o1o o2n o2o o3n o3o c1n c1v c2n c2v c3n c3v small large)) or d +ie $dbh->errstr;
In fact, there's still far too much regularity in that code for my taste. You should abstract out the fields and mapping from form names to db columns.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: called with 19 bind variables when 20 are needed, error
by andrew (Acolyte) on Jul 20, 2002 at 22:08 UTC
    $sth->execute(map scalar param($_), qw(cat itemid price des longdes size o1n o1o o2n o2o o3n o3o c1n c1v c2n c2v c3n c3v),$small,$large) or die $dbh->errstr; Why doesnt that work
      Because $small and $large are being passed through the map. You need to add parens to the map arg list:
      $sth->execute(map(scalar param($_), qw(cat itemid price des longdes si +ze o1n o1o o2n o2o o3n o3o c1n c1v c2n c2v c3n c3v)),$small,$large) o +r die $dbh->errstr;

      -- Randal L. Schwartz, Perl hacker