2015-01-09 119 views
0

我正在WordPress的目錄網站,當我嘗試我得到這個錯誤的搜索選項:WordPress的錯誤:警告非法偏移

警告:非法串偏移「場」在/ home/dalilouk /public_html/wp-content/themes/directory/header.php on line 27

警告:/home/dalilouk/public_html/wp-content/themes/directory/header.php在線的非法字符串偏移「字段」 33

而搜索的結果總是「找不到」。

這是header.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> 

請幫我解決這個問題。

回答

0

它不是PHP源代碼。您只是在瀏覽器中打開該PHP,所以您發佈的是PHP腳本輸出。您必須在某個編輯器中打開真正的.php文件,並向我們顯示源代碼:)

通過您的問題 - 這不是錯誤,它關於調用變量的警告,它並未設置在某個點上。所以你的腳本仍然有效,但可能你的表單有錯誤的域名發送,所以你的PHP腳本無法找到你想要搜索的數據,因爲找不到那個特定的變量。

+0

感謝您的回覆,對不起,我是新手,能否告訴我該如何找到.php文件? – Rori

+0

你部署了應用程序(很多.php文件)到你的服務器,可能通過ftp/sftp :)所以,你也可以從你的ftp/sftp下載它。 – Anton

相關問題