problem with has_post_thumpnail in foreach loop

Use this code instead of has_post_thumbnail()

if ( '' != get_the_post_thumbnail() ) {
    // some code
}

Please refer below link for more information

http://codex.wordpress.org/Function_Reference/has_post_thumbnail