Small php error-Help please

3 replies
  • WEB DESIGN
  • |
I have small php error for <?php endif; usage.
On line 41
You can check it here.
PHP Code Checker - Syntax Check for Common PHP Mistakes

Can you help me?


<?php
/**
* @package WordPress
* @subpackage U-Design
*/

global $udesign_options;

// construct an array of portfolio categories
$portfolio_categories_array = explode( ',', $udesign_options['portfolio_categories'] );

if ( $portfolio_categories_array != "" && post_is_in_category_or_descendants( $portfolio_categories_array ) ) :
// Test if this Post is assigned to the Portfolio category or any descendant and switch the single's template accordingly
include 'single-Portfolio.php';
else : // Continue with normal Loop (Blog category)

get_header();

$content_position = ( $udesign_options['blog_sidebar'] == 'left' ) ? 'grid_16 push_8' : 'grid_16';
if ( $udesign_options['remove_single_sidebar'] == 'yes' ) $content_position = 'grid_24';
?>
<div id="content-container" class="container_24">
<div id="main-content" class="<?php echo $content_position; ?>">
<div class="main-content-padding">
<?php do_action('udesign_above_page_content'); ?>
<?php if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="entry">
<?php echo types_render_field("employ-image", array("size" => "thumbnail", "align" => "left"));?>

<?php // Post Image
if( $udesign_options['display_post_image_in_single_post'] == 'yes' ) display_post_image_fn( $post->ID, false );
the_content(__('<p class="serif">Read the rest of this entry &raquo;</p>', 'udesign'));
wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

</div>
</div>
<?php
endif; // end meta ?>


</div><!-- end main-content-padding -->
</div><!-- end main-content -->
<?php
if( ( !$udesign_options['remove_single_sidebar'] == 'yes' ) && sidebar_exist('BlogSidebar') ) { get_sidebar('BlogSidebar'); }
?>
</div><!-- end content-container -->
<?php
endif; // end normal Loop ?>

<div class="clear"></div>

<?php

get_footer();
#errorhelp #php #small
  • Profile picture of the author BrainyBiz
    Take a look at Alternative syntax for control structures on php.net. It will explain how to format your code.

    From what I can see in the code you posted you might be missing a few colons in your if statements. It's hard to be sure without having all the code that is involved.
    {{ DiscussionBoard.errors[9141193].message }}
  • Profile picture of the author 723Media
    There are a few problems going on.

    1. You have a mixture of the traditional {} syntax and the newer if: endif; - While that isn't going to break code, it can throw some people off. I would stick to one style for sanity.

    2. You also have some "non-enclosed" if statements.
    if ( $udesign_options['remove_single_sidebar'] == 'yes' ) $content_position = 'grid_24';
    Again, this won't break your code but it makes it very easy to accidentally add a second line to the statement, which can cause unexpected results.

    The actual error is that you began a while loop without ending it. That's why the endif usage is invalid.
    {{ DiscussionBoard.errors[9141246].message }}
    • Profile picture of the author alkantenik
      Very thanks 723 Media I fixed it with your help..
      Signature
      Wordpress Designer
      Skype: wordpress_alkan
      {{ DiscussionBoard.errors[9142386].message }}

Trending Topics