757design Posted August 6, 2014 Share Posted August 6, 2014 (edited) 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; ?> Edited August 6, 2014 by mac_gyver code tags please Quote Link to comment https://forums.phpfreaks.com/topic/290299-parse-error-syntax-error-unexpected-t_endwhile/ Share on other sites More sharing options...
PravinS Posted August 6, 2014 Share Posted August 6, 2014 (edited) you have only 1 while loop and 2 endwhile Edited August 6, 2014 by PravinS Quote Link to comment https://forums.phpfreaks.com/topic/290299-parse-error-syntax-error-unexpected-t_endwhile/#findComment-1486964 Share on other sites More sharing options...
mogosselin Posted August 6, 2014 Share Posted August 6, 2014 '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?'. Quote Link to comment https://forums.phpfreaks.com/topic/290299-parse-error-syntax-error-unexpected-t_endwhile/#findComment-1486969 Share on other sites More sharing options...
Jacques1 Posted August 6, 2014 Share Posted August 6, 2014 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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/290299-parse-error-syntax-error-unexpected-t_endwhile/#findComment-1486971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.