2011-01-06 184 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);