try this:

my %select =
  (
     no_contractor => 'select blah1, blah2 from contractors where 
(username = ?) and
                             (password = ?)',
     with_contactor => 'select blah1, blah2 from ap_contractors where 
(id = ?)'
);
my $dbh = DBI->connect("DBI:mysql:$database:$hostname", $user, 
$datpassword);
my $sth;
unless ($contractor_id)  {
    $sth = $dbh->prepare($select{with_contractor});
    $sth->execute($username,$password);
} else {
    $dbh->prepare($select{no_contractor});
    $sth->execute($contractor_id)
}


On Monday, October 22, 2001, at 06:36 PM, Greg Thompson wrote:
>
> I know this is probably simple, but I do not know why it does not 
> perform
> the selection based on my if statements. I've tried selecting stuff 
> using
> other if statements, and they did not work either. But once I take away 
> the

you need to examine your data with a microscope and that microscope is 
Data::Dumper.. get it from http://kobesearch.cpan.org



> if/else statement, it works fine, but then the problem remains that I 
> need

if/else is often best cast with hashes, as shown above... and later with 
object-oriented dispatch, but that is 6 months down the road :)

Reply via email to