if (defined $status) { $statement = $dbh->prepare('SELECT COUNT(*) FROM name WHERE status = "' . "$status" . '"') or die DBI->errstr; } else { $statement = $dbh->prepare('SELECT COUNT(*) FROM name WHERE age = "4"') or die DBI->errstr; $status = 'OPEN'; } $sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped"; $sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped"; my $count = $sth->fetchrow_array(); $sth->finish; #### Couldn't execute statement: You have an error in your SQL syntax near 'DBI::st=HASH(0x8298e60)' at line 1;