This isn't perfect as you do not quote $status. It is often better to let DBI do that for you:
my $arg; if(defined $status) { $statement = 'SELECT COUNT(*) FROM name WHERE status=?;'; $arg = $status; } else { $statement = 'SELECT COUNT(*) FROM name WHERE age=?;'; $arg=4; } $sth = $dbh->prepare($statement) or die "Cannot Prepare $DBI::errstr"; $sth->execute($arg) or die "Cannot execute $DBI::errstr";
Calling the statement this way makes sure the data is properly quoted.
$japh->{'Caillte'} = $me;
In reply to Re: Re: MySQL Error
by Caillte
in thread MySQL Error
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |