How to use Perl's DBI connect when no mysql passwd is set?

I am getting the error "Can't call method "prepare" on an undefined value at..." with the following code:

<code>my %dbh;
my $dbh = DBI->connect("DBI:mysql:Customer_Data",
$username,
$password
) or die "Database connection failed.";

$myquery="SELECT * from Site";
$execute = $connect->prepare($myquery);
$execute->execute() or die $dbh->errstr;
</code>

Can anyone suggest what might be the problem?

I can't see where $connect is assigned a value. Try $dbh->prepare.