Why does the following code works

Code:
$dbh = DBI->connect("DBI:mysql:$database2:$dbserver",$dbusername,$dbpassword);
while this one doesn't?

Code:
$dbh = DBI->connect("DBI:mysql:$database2:$dbserver",$dbusername,$dbpassword) or die "Can't make 1st database connect: $DBI::errstr\n";