http://qs321.pair.com?node_id=608251

Win has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Error with the bind_param
by Ovid (Cardinal) on Apr 04, 2007 at 11:13 UTC

    That's because $sthB_A is undefined. The do() method will take a prepared statement, though.

    my $sthB_A = $dbh->prepare($Command_B); my $count = 1; foreach (@CHOICE_B[1 .. $elements_in_array_B]){ $sthB_A->bind_param($count, $_); $count++; } my $result = $dbh->do($sthB_A) or die "Couldn't do query: ".$dbh->err +str;

    Cheers,
    Ovid

    New address of my CGI Course.

Re: Error with the bind_param
by roboticus (Chancellor) on Apr 04, 2007 at 11:14 UTC
    Win:

    >Sigh<

    You need to actually have a statement handle to execute bind_param on it. You're trying to do your binding before you create it. Something like painting a house before you build it....

    ...roboticus

Re: Error with the bind_param
by davidrw (Prior) on Apr 04, 2007 at 11:53 UTC
    are you _sure_ @CHOICE_B[1 .. $elements_in_array_B] is what you want? Seems like it should be just @CHOICE_B ...

    You can also simplify the whole thing (see DBI docs) into one line:
    my $rv = $dbh->do($Command_B, {}, @CHOICE_B) or die "Couldn't do query +: ".$dbh->errstr;