2011-01-06 176 views
1

我使用zend框架順便說一句,我已經實現了ZendX_JQuery_Form_Element_AutoComplete。它在我的本地系統上按預期工作,但在實時服務器上,當我開始輸入時,它會給我一個500內部服務器錯誤。我已經有3天這個問題了,而且我已經使用Google並閱讀了很少的解決方案。500服務器上的內部服務器錯誤,但在開發系統上工作

希望有人能幫忙。

服務器和開發系統都運行Ubuntu,我試圖在兩個系統上保持相同的設置。

編輯:

我檢查了鏈接和許可的建議和問題仍然存在。所以我所做的就是從字面上運行的代碼行由行,我來到了以下行觸發錯誤500控制器:

$response = $groupsmapper->search($this->getRequest()->getParam('term')); 
下面

是完整的功能

public function getallgroupnamesAction() 
{ 
    $this->_helper->viewRenderer->setNoRender(); 
    $this->_helper->getHelper('layout')->disableLayout(); 
    $groupsmapper = new Application_Model_GroupsMapper(); 

    $response = $groupsmapper->search($this->getRequest()->getParam('term')); 
    $json = Zend_Json::encode(array_values($response)); 
    echo $json; 
} 

和groupsmapper的搜索方法是像這樣

public static function search($term) 
{ 
    $groupsmapper = new Application_Model_GroupsMapper(); 
    $response = $groupsmapper->getDbTable()->fetchAll(
        $groupsmapper->getDbTable() 
        ->select() 
        ->distinct() 
        ->from(array('groups'), array('group_name')) 
      ); 

    $no_groups = count($groups_array = $response->toArray()); 

    for ($x = 0; $x < $no_groups; $x++) 
    { 
     $groups[] = $groups_array[$x]['group_name']; 
    } 


    $filter = function($group) use ($term) 
    { 
     if(stristr($group, $term)) 
      return true; 
     return false; 
    }; 
    return array_filter($groups, $filter); 
} 

我真的希望你們能發現什麼,其他明智的方案是使用select元素,但該列表將過長或讓用戶輸入名稱並單擊提交按鈕進行搜索。這也不是很理想,因爲拼寫不常見或不容易找出,因此查詢可能不總是鍛鍊。

+5

錯誤日誌實際上對錯誤消息的詳細信息說了什麼?沒有更多的細節,這是不可能的。 – artlung 2011-01-06 15:00:42

回答

1

檢查服務器上運行的文件的chmod。我的猜測是權限設置爲你的主機不贊成的東西。

0

嘗試檢查您的路徑。也許在本地服務器上你的路徑是正確的,但在真正的服務器上這個路徑是錯誤的。使用絕對路徑的最佳做法。在Zend Framework的index.php中,你可以聲明ROOT_PATH和其他路徑。在其他頁面上,當你包含一些文件時,使用這個全局變量。服務器無法在服務器上找到文件(500內部錯誤)。對不起我的英語不好。

0

您可以通過註釋下面的代碼行刪除回調函數

/* //lines to comment 
$filter = function($group) use ($term) 
{ 
    if(stristr($group, $term)) 
     return true; 
    return false; 
}; 
return array_filter($groups, $filter); 
*/ 

包括您自己的功能,將它傳遞的回調函數,它肯定會工作。我通過使用以下幾行克服了同樣的問題。

//New lines to include 
    function filtergroup() 
    { 
     return true; 
    } 

    return array_filter($groups, $filtergroup);