pixelwm Posted June 20, 2009 Share Posted June 20, 2009 I hope I have the right forum here... but anyway, I am working on a wordpress theme and it uses some conditionals for header images based on whether a person is on a front page, page, post, or category so I came across separate snippets of php that do the above and when I put them together it works fine in my demo site but wordpress.org said they got an error: PHP Parse error: syntax error, unexpected $end in /usr/home/web/theme-test/public_html/wp-content/themes/evening-shade/advertise.php on line 40 The file in question is brought into the page with a typical includes: <?php include (TEMPLATEPATH . '/advertise.php'); ?> but the file itself is made up of the following code: <?php if (is_front_page()) { ?> <div id="advert1"></div> <?php } else { ?> <?php // Custom Headers for pages and posts with custom fields if (get_post_meta($post->ID, 'header', true)) { ?> <div id="advert1"><img src="<? bloginfo('url'); ?>/wp-content/uploads/<? echo get_post_meta($post->ID, 'header', true) ?>" alt="<?php the_title(); ?>" /></div> <? } else { ?> <?php /**** Conditional Header for Per Category Example Wordpress ****/ // make sure we are in category listing if (is_category()){ if (is_category('3')){ include(TEMPLATEPATH.'/headers/vineyardnews.php'); } elseif (is_category('5')){ include(TEMPLATEPATH.'/headers/experiences.php'); } else { // this is the deafult header include(TEMPLATEPATH.'/headers/default.php'); } } ?> <? } ?> <?php } ?> Even though this works live in a site, I am trying to figure out what is not correct. Does anyone have an idea of what is creating the error the guy got? Thanks in Advance. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 20, 2009 Share Posted June 20, 2009 http://www.phpfreaks.com/forums/index.php/topic,257485.msg1211328.html#msg1211328 ; NOTE: Using short tags should be avoided when developing applications or ; libraries that are meant for redistribution, or deployment on PHP ; servers which are not under your control, because short tags may not ; be supported on the target server. For portable, redistributable code, ; be sure not to use short tags. Quote Link to comment Share on other sites More sharing options...
pixelwm Posted June 20, 2009 Author Share Posted June 20, 2009 First up, I forgot to mention my PHP knowledge is far before that of a beginner The code snippets I got above were from another source which completely had theirs all wrong and someone commented how to correct it which is what I used. Then I tried to do the if and else for the conditionals... So straight to the point, thanks for the reply, but I am still in the dark here and trying to figure out why the code works but they said it has a parsing error. I did find a site so if I read right, short tags is bad coding technique as some host servers don't support it and short tags are like or referring to '<?' when a full tag is '<?php'. So basically what I have above works but needs to be rewritten? If so, now I'm really stuck because again, I am no php guru. Quote Link to comment Share on other sites More sharing options...
cikitani Posted June 21, 2009 Share Posted June 21, 2009 Can't you post the lines 48 39 40 41 and 42? Quote Link to comment Share on other sites More sharing options...
pixelwm Posted June 21, 2009 Author Share Posted June 21, 2009 Can't you post the lines 48 39 40 41 and 42? Actually the script as you see is as it is. The only thing I left out was the top of it which was just comments only. The line mentioned in the error was the very last line of the file which was actually a blank line...nothing there. Plus when I posted the script here, just to make it shorter I removed some extra blank lines. So what you see is actually the full file (minus the comments part). Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 21, 2009 Share Posted June 21, 2009 So, what is the problem you are having with fixing the php tags? Just edit the code and change all the <? into <?php Quote Link to comment Share on other sites More sharing options...
pixelwm Posted June 21, 2009 Author Share Posted June 21, 2009 As I said I am a complete beginner on this so if that is all that is needed, then I will try it out and resubmit the theme to wordpress.org and see if it works for them. Thanks. Quote Link to comment 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.