我收到了一个意外的endforeach错误但没有任何改变

时间:2014-06-30 13:55:08

标签: php wordpress

我开始收到以下错误消息:

Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH) in /home/paintpricescompa/public_html/wp-content/themes/compare/_includes/price-table.php on line 89

然而,没有任何改变,即文件内容等。下面是代码,任何帮助?

<?php

include(TEMPLATEPATH.'/_functions/get-options.php');
if(!function_exists('dont_cut_words')){
include(TEMPLATEPATH.'/_includes/utils.php');
}
$deeplinkInSameWindow = get_option('tz_price_comparison_table_open_deeplink_in_same_window');
$unicalPriceTableId = mt_rand();$current_blog_id = get_current_blog_id();
?>
<script type="text/javascript">     
jQuery(document).ready(function(){
    jQuery('.paginator-<?php echo $unicalPriceTableId; ?>').smartpaginator({ totalrecords: <?php echo $merchants_length; ?>, recordsperpage: <?php if (isset($tz_products_per_page) && is_numeric($tz_products_per_page)){ if($merchants_length >= $tz_products_per_page) { echo $tz_products_per_page; } else { echo $merchants_length; } } else {  echo "10";}; ?>, datacontainer: 'price-comparison-table-<?php echo $unicalPriceTableId; ?>', dataelement: 'tr', initval: 0, next: 'Next', prev: 'Prev', first: 'First', last: 'Last', theme: 'black' });
    });
</script>
<table id="price-comparison-table-<?php echo $unicalPriceTableId; ?>" class="single-product prices-table" cellpadding="0" cellspacing="0">
<thead>
    <tr>
        <th>&nbsp;</th>
        <th><?php _e('Product','framework'); ?></th>
        <th><?php _e('Retailer','framework'); ?></th>
        <th class="thead-price sort-numeric"><div><?php _e('Price','framework'); ?></div></th>
    </tr>
</thead>
<tbody>
<?php foreach($merchants as $merchant): ?>
    <tr>
        <td class="image-column">
            <?php if($merchant->feed_product_image != ''): ?>
            <img src="<?php echo str_replace('&','&amp;',$merchant->feed_product_image); ?>" alt="<?php echo $merchant->feed_product_name; ?>" />
            <?php endif; ?>
        </td>
        <td class="product-column">
            <span class="product-title"><?php echo stripslashes($merchant->feed_product_name); ?></span><br />
            <?php echo dont_cut_words($merchant->feed_product_desc,100); // echo substr(strip_tags($merchant->feed_product_desc),0,100); ?><br />
            <?php if($merchant->voucher != ''): ?>
            <span class="product-voucher">
            <?php _e('VOUCHER CODE:','framework'); ?> <?php echo $merchant->voucher ?>
            </span>
            <?php endif; ?>
        </td>
        <td class="merchant-column">                            <?php                               if($current_blog_id == 1){                  $uploadDirCategoriesAbsolute = ABSPATH.'wp-content/uploads/compare/merchants/';                 $uploadDirCategories = '/wp-content/uploads/compare/merchants/';                                    } else {                    // For WP multisite installation                    $uploadDirCategoriesAbsolute = ABSPATH.'wp-content/uploads/compare/merchants/'.$current_blog_id.'/';                    $uploadDirCategories = '/wp-content/uploads/compare/merchants/'.$current_blog_id.'/';               }               ?>
            <?php if($merchant->image != "" && file_exists($uploadDirCategoriesAbsolute.$merchant->image)): ?>
                <a class="image" href="<?php echo str_replace('&','&amp;',$merchant->deeplink); ?>" rel="nofollow"><img src="<?php echo home_url().$uploadDirCategories.$merchant->image; ?>" alt="<?php echo stripslashes($merchant->name); ?>" title="" /></a>
            <?php else: ?>
            <a href="<?php echo str_replace('&','&amp;',$merchant->deeplink); ?>" rel="nofollow"><?php echo stripslashes($merchant->name) ?></a><br />
            <?php endif; ?>
            <small><?php _e('Last update:','framework'); echo ' '.date((get_option('tz_date_format') != '' ? get_option('tz_date_format') : 'd-m-Y H:i'),$merchant->last_update); ?></small>
        </td>
        <td class="price-column">
            <span class="product-price">
            <?php 
                $product_price = number_format($merchant->price,2,'.','');
                if(compare_get_currency('position') == "left"){ 
                    echo str_replace(array("\r\n", "\r", "\n", " "), "", compare_get_currency('symbol')).$product_price;
                } 
                else
                {
                    echo $product_price.str_replace(array("\r\n", "\r", "\n", " "), "", compare_get_currency('symbol'));
                }
            ?>
            </span><br /> 
            <?php
                if($merchant->shipping != '') {
                    $merchant->shipping = str_replace(',','.',$merchant->shipping);
                    if(is_numeric($merchant->shipping)) {

                        _e('Delivery:','framework');
                        echo ' ';
                        $merchant->shipping = number_format($merchant->shipping,2,'.','');
                        if(compare_get_currency('position')  == "left"){ 
                            echo str_replace(array("\r\n", "\r", "\r", " "), "", compare_get_currency('symbol')).$merchant->shipping;
                        } 
                        else
                        {
                            echo $merchant->shipping.str_replace(array("\r\n", "\r", "\r", " "), "", compare_get_currency('symbol'));
                        }

                    } else {
                        echo '<a class="tiptip" title="'.$merchant->shipping.'">';
                        _e('Delivery','framework');
                        echo '</a>';
                    }
                    echo '<br />';
                }
            ?>
            <a class="zum_shop" <?php echo ((isset($deeplinkInSameWindow) && $deeplinkInSameWindow == 'true')) ?  "" : "target='_blank'" ?> rel="nofollow" href="<?php echo str_replace('&','&amp;',$merchant->deeplink); ?>"><?php echo (isset($tz_buy_button_text) && $tz_buy_button_text != '') ? stripslashes($tz_buy_button_text) : __('BUY NOW','framework'); ?></a>
        </td>
    </tr>
<?php endforeach; ?>
</tbody>
</table>

<input type="text" class="merchants_length_input" style="display:none" value="<?php echo $merchants_length; ?>" />
<input type="text" class="products_per_page_input" style="display:none" value="<?php if (isset($tz_products_per_page) && is_numeric($tz_products_per_page)){ if($merchants_length >= $tz_products_per_page) { echo $tz_products_per_page; } else { echo $merchants_length; } } else {  echo "10";}; ?>" />

<div class="paginator-<?php echo $unicalPriceTableId; ?>" style="margin: auto;">
</div>

2 个答案:

答案 0 :(得分:0)

请记住,当您在脚本上添加以下注释时?

// For WP multisite installation

它只是在代码中注释了else block的右括号。那就是触发错误。

它在线#41

<td class="merchant-column">                            <?php                               if($current_blog_id == 1){                  $uploadDirCategoriesAbsolute = ABSPATH.'wp-content/uploads/compare/merchants/';                 $uploadDirCategories = '/wp-content/uploads/compare/merchants/';                                    } else {                    // For WP multisite installation                    $uploadDirCategoriesAbsolute = ABSPATH.'wp-content/uploads/compare/merchants/'.$current_blog_id.'/';                    $uploadDirCategories = '/wp-content/uploads/compare/merchants/'.$current_blog_id.'/';               }               ?>

答案 1 :(得分:0)

中存在语法错误
<td class="merchant-column">                            <?php                               if($current_blog_id == 1){                  $uploadDirCategoriesAbsolute = ABSPATH.'wp-content/uploads/compare/merchants/';                 $uploadDirCategories = '/wp-content/uploads/compare/merchants/';                                    }   ?>
            <?php if($merchant->image != "" && file_exists($uploadDirCategoriesAbsolute.$merchant->image)): ?>
                <a class="image" href="<?php echo str_replace('&','&amp;',$merchant->deeplink); ?>" rel="nofollow"><img src="<?php echo home_url().$uploadDirCategories.$merchant->image; ?>" alt="<?php echo stripslashes($merchant->name); ?>" title="" /></a>
            <?php else: ?>
            <a href="<?php echo str_replace('&','&amp;',$merchant->deeplink); ?>" rel="nofollow"><?php echo stripslashes($merchant->name) ?></a><br />
            <?php endif; ?>
            <small><?php _e('Last update:','framework'); echo ' '.date((get_option('tz_date_format') != '' ? get_option('tz_date_format') : 'd-m-Y H:i'),$merchant->last_update); ?></small>
        </td>

如果在这种情况下不会发生任何事情,则无需使用其他部分。

只需替换此div(已更正)并运行您的代码。