I get error in my code, please help, unexpected 'endwhile'!

Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE) in index.php on line 61


<?php
global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
?>
<?php get_header(); ?>
<div id="slider">
<img src="<?php bloginfo('template_url');?>/images/slider/1.jpg" alt="" />
<img src="<?php bloginfo('template_url');?>/images/slider/2.jpg" alt="" />
<img src="<?php bloginfo('template_url');?>/images/slider/3.png" alt="" />
</div>
<div id="wrap">
    <div id="main">
                <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); 
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
        ?>
            <div class="poster">
                <div class="leftside">
                    <div class="inline-byline">
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="date-num"><?php the_time('j') ?></a>
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="date-month"><?php the_time('M') ?></a>
                        <span>Autor/span> <span class="inline-byline-author"><?php the_author_posts_link(); ?></span>
                        <span class="comment"><?php comments_popup_link('0', '1', '%'); ?></span>
                     </div>
                </div>
                        
            <div class="post postcontent">
            <?
            // checks if thumbnails are disabled
            if ($xs_disable_thumbnails_archieve == "true") { ?>
          <? } else { ?>
                <?php
                    if ( has_post_thumbnail() ) { 
                    // the current post has a thumbnail
                    ?>
                    <div class="thumbnail-wrap">
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $thumbnail[0]; ?>" height="270" width="560" alt="<?php the_title(); ?>" class="thumbnail" /></a>
                    </div><!-- /thumbnail-wrap -->
                    <? } else { 
                    // the current post lacks a thumbnail
                    ?>
                <? } ?>
            <? } ?>
            <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
            <?
            // checks if the byline is disabled
            if ($xs_disable_inline_byline == "true") { ?>
            <?
            // if not show byline
             } else { ?>
            
            <? } ?>
        <?php the_excerpt(); ?>
        
                </div><!-- /post postcontent -->
                <div class="clear"></div>
                </div>
                
<?php endwhile; ?> // <-- I get Error here
<?php endif; ?>
        <?php
            //Check For the Page Navi Plugin
            if (function_exists('wp_pagenavi')) {
                   wp_pagenavi();
            //Show Default Navigation if Page Navi Is Not Installed
            } else { ?>
                   <div id="paginate">
                    <div id="paginate-left"><?php previous_posts_link('Newer Posts') ?></div>
                    <div id="paginate-right"><?php next_posts_link('Older Posts') ?></div>
                </div><!-- /paginate -->
            <? } ?>
</div><!-- End Main -->        
<?php get_sidebar(); ?>    
<?php get_footer(); ?>

 <?php while (have_posts()) : the_post(); 

That line looks to be the problem, ending the while loop…

Try something like:

 
// stick to the "alternative syntax" for your while loop...
<?php while (have_posts()) : ?>
<?php
the_post(); 
// .. carry on



i still get the same error.