WordPress错误:警告非法偏移


WordPress Error: Warning Illegal Offset

我正在wordpress上的目录网站上工作,当我尝试搜索选项时,我收到此错误:

警告:第 27 行/home/dalilouk/public_html/wp-content/themes/directory/header.php 中的非法字符串偏移量"字段"

警告:第 33 行/home/dalilouk/public_html/wp-content/themes/directory/header.php 中的非法字符串偏移量"字段"

搜索的结果总是"找不到"。

这是标头的代码.php来自第 27 行:

<script type="text/javascript">            #line 27
jQuery(document).ready(function($) {
    {ifset $themeOptions->search->searchCategoriesHierarchical}
    var categories = [ {!$categoriesHierarchical} ];
    {else}
    var categories = [                #line 33
    {foreach $categories as $cat}
        { value: {$cat->term_id}, label: {$cat->name} }{if !($iterator->last)},{/if}
    {/foreach}
    ];
    {/ifset}
    {ifset $themeOptions->search->searchLocationsHierarchical}
    var locations = [ {!$locationsHierarchical} ];
    {else}
    var locations = [
    {foreach $locations as $loc}
        { value: {$loc->term_id}, label: {$loc->name} }{if !($iterator->last)},{/if}
    {/foreach}
    ];
    {/ifset}
    var catInput = $( "#dir-searchinput-category" ),
        catInputID = $( "#dir-searchinput-category-id" ),
        locInput = $( "#dir-searchinput-location" ),
        locInputID = $( "#dir-searchinput-location-id" );
    catInput.autocomplete({
        minLength: 0,
        source: categories,
        focus: function( event, ui ) {
            var val = ui.item.label.replace(/&amp;/g, "&");
                val = val.replace(/&nbsp;/g, " ").replace(/&#039;/g, "'");
            catInput.val( val );
            return false;
        },
        select: function( event, ui ) {
            var val = ui.item.label.replace(/&amp;/g, "&");
                val = val.replace(/&nbsp;/g, " ").replace(/&#039;/g, "'");
            catInput.val( val );
            catInputID.val( ui.item.value );
            return false;
        }
    }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
        return $( "<li>" )
            .data( "item.autocomplete", item )
            .append( "<a>" + item.label + "</a>" )
            .appendTo( ul );
    };
    var catList = catInput.autocomplete( "widget" );
    catList.niceScroll({ autohidemode: false });
    catInput.click(function(){
        catInput.val('');
        catInputID.val('0');
        catInput.autocomplete( "search", "" );
    });
    locInput.autocomplete({
        minLength: 0,
        source: locations,
        focus: function( event, ui ) {
            var val = ui.item.label.replace(/&amp;/g, "&");
                val = val.replace(/&nbsp;/g, " ").replace(/&#039;/g, "'");
            locInput.val( val );
            return false;
        },
        select: function( event, ui ) {
            var val = ui.item.label.replace(/&amp;/g, "&");
                val = val.replace(/&nbsp;/g, " ").replace(/&#039;/g, "'");
            locInput.val( val );
            locInputID.val( ui.item.value );
            return false;
        }
    }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
        return $( "<li>" )
            .data( "item.autocomplete", item )
            .append( "<a>" + item.label + "</a>" )
            .appendTo( ul );
    };
    var locList = locInput.autocomplete( "widget" );
    locList.niceScroll({ autohidemode: false });
    locInput.click(function(){
        locInput.val('');
        locInputID.val('0');
        locInput.autocomplete( "search", "" );
    });

    {ifset $_GET['dir-search']}
    // fill inputs with search parameters
    $('#dir-searchinput-text').val({$searchTerm});
    catInputID.val({$_GET["categories"]});
    for(var i=0;i<categories.length;i++){
        if(categories[i].value == {$_GET["categories"]}) {
            var val = categories[i].label.replace(/&amp;/g, "&");
                val = val.replace(/&nbsp;/g, " ").replace(/&#039;/g, "'");
            catInput.val(val);
        }
    }
    locInputID.val({$_GET["locations"]});
    for(var i=0;i<locations.length;i++){
        if(locations[i].value == {$_GET["locations"]}) {
            var val = locations[i].label.replace(/&amp;/g, "&");
                val = val.replace(/&nbsp;/g, " ").replace(/&#039;/g, "'");
            locInput.val(val);
        }
    }
    {/ifset}
});
</script>

请帮我解决这个问题。

它不是PHP源代码。您刚刚在浏览器中打开了该php,因此您发布的是该PHP脚本输出。您必须在某个编辑器中打开真实的.php文件,并向我们展示源代码:)

通过您的问题 - 这不是错误,它是关于调用变量的警告,该变量未在某些点上设置。所以你的脚本仍然有效,但可能你的表单有错误的字段名称要发送,所以你的php脚本无法找到你想要搜索的数据,因为找不到那个特定的变量。