Jump to content

Parse error: syntax error, unexpected T_ENDWHILE


757design

Recommended Posts

can some one help me with this code I'm getting a Parse error: syntax error, unexpected T_ENDWHILE error code on the last line of code. source code below

 

 

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


                   
                      <h1><?php the_title(); ?></h1>
                      
<?php get_template_part( 'content', 'page' ); ?>


                    </div>


<?php thinkup_input_allowcomments(); ?>






<?php endwhile; wp_reset_query(); ?>
              
                  <?php $mytrails = new WP_Query(array( 
                               'post_type' => '$mytrails'
                          )); ?>
                   <?php endwhile; ?>

'unexpected T_ENDWHILE' really means 'Dude, I see an 'endwhile' and I didn't expect it at all... what the hell is that?'. Sometimes, those error messages means that you are missing a ';' character at the end of a line and then PHP sees the next 'statement' (which is not a ';') and will spit this error.

 

But, like ParvinS said, in your case, you have two 'endwhile' and just one 'while loop'. PHP saw your last 'endwhile' and tought 'what the hell is that? I didn't see any 'while' and now you want to end it?'.

You know how you can avoid those errors? Proper formatting.

 

No offense, but this is a mess even for a Wordpress template. Indentation and visual structuring isn't just nice-to-have. It's a major part of writing correct code. If you you write a mess, then you first confuse other readers, then yourself and finally the parser. You've reached the last stage.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.