Because you’re using semicolons when you should be using colons after the if
and the while
🙂
query_posts( 'year=2011' );
if ( have_posts() ):
while ( have_posts() ):
the_post();
the_title();
endwhile;
wp_reset_query();
endif;
That works just fine.