Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我收到一个意外的endforeach错误,但没有任何更改_Php_Wordpress - Fatal编程技术网

Php 我收到一个意外的endforeach错误,但没有任何更改

Php 我收到一个意外的endforeach错误,但没有任何更改,php,wordpress,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.'/_funct

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

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>

还记得你在脚本上添加下面的注释吗

// For WP multisite installation
它只是注释掉了代码中else块的右大括号。这触发了错误

它在41号线


中存在语法错误

<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并运行您的代码。

在线提供了大量免费的php代码语法检查器。
<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>