in reply to Why do I keep getting this error message?

Or if you have some reason to suspect that there are valid circumstances where $month or $year1 are not getting assigned, you could always test them:
unless ( $month && $year1 ) { # your error code here... }