Jump to content

Is there something not right about this code?


pixelwm

Recommended Posts

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.

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.

First up, I forgot to mention my PHP knowledge is far before that of a beginner  ;D

 

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.

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).

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.