my $sth = $dbh->prepare("SELECT * FROM logs where datetime like '?'")
           or die $dbh->errstr;
                print "Enter datetime: ";
                while ($datetime = <>) {
                   my @data;
                           chomp $datetime;
                                   $sth->execute($datetime) or die $sth->errstr;

then I am prompted to enter a date, which I can, but immediately after
that:

DBD::mysql::st execute failed: called with 1 bind variables when 0 are
needed at datetime.pl line 19, <> line 1.

>> I've seen this, too.  You might try using a naked ? without the single 
>> quotes.

If I define $datetime beforehand and interpolate it in the query, it
works, but I read here that it is not reccommended:

>> True that it's not recommended, because for each iteration the query will 
>> need to be re-parsed, but if you are not executing this query a million 
>> times, it probably won't matter much.

Reply via email to