2014-09-04 54 views
0

我在codeigniter框架中做了一個web應用程序。我正在Windows機器上開發應用程序,並且最終版本在相同的情況下運行得非常好(即windows,wamp,精確爲)。 現在我需要在Ubuntu服務器上部署應用程序。在應用程序所需的初始登錄後,它不會顯示任何其他page.On檢查控制檯,我發現這個在windows和linux中使用codeigniter時的命名約定問題

[09:08:37.255] GET http://localhost/sac.org/index.php/member [HTTP/1.0 500 Internal Server Error 17ms] 

我覺得這是一個很常見的問題,從這些問題是顯而易見的:

codeigniter framework not working on linux

Windows code not working on linux

codeigniter upload not working on linux

,並在這裏o Codeigniter issue

等等。在這些線程中提到的答案不適合我。 有沒有辦法解決這個問題?

我的代碼示例是

<?php 
class member extends CI_Controller{ 
    public $data1 = ""; 
    public function __construct(){ 
     parent::__construct(); 
     $this->load->helper('form'); 
     $this->load->helper('url'); 
     $this->load->library('session'); 
     $this->load->library('table');  
     $this->load->model('membermodel'); 
     $this->data1 = $this->membermodel->getYearList(); 
    } 
    private function accesscheck(){ 
     $privilege = $this->session->userdata('privilege'); 
     if($privilege=='2'||$privilege=='1'){ 
      return "True"; 
     } 

    } 

    public function index(){ 
     echo phpinfo(); 
     die(); 
     if($this->accesscheck()){ 
     $data = array('years'=>$this->membermodel->getYearList()); 
     $notifications = $this->membermodel->numberOfNotifications(); 
     $this->session->set_userdata('notifications',$notifications); 
     $this->load->view('templates/header',$data); 
     $this->load->view('templates/menu'); 
     $this->load->view('members/home',$data); 
     $this->load->view('templates/footer'); 

    } 
else{ 
    $this->load->view('templates/accessErr'); 
}} 

    public function year($year){ 
     if($this->accesscheck()){ 

      $this->getTable($year,"FullList"); 


    }else{ 
    $this->load->view('templates/accessErr'); 
}} 

    public function positive($year){ 
     if($this->accesscheck()){ 
      $this->gettable($year,"positive"); 
     }else{ 
      $this->load->view('templates/accessErr'); 
     } 
    } 
    public function negative($year){ 
       if($this->accesscheck()){ 

        $this->getTable($year,"negative"); 

} 
    else{ 
    $this->load->view('templates/accessErr'); 
}} 
    public function neutral($year){ 
       if($this->accesscheck()){ 
      $this->getTable($year,"neutral"); 


    }else{ 
    $this->load->view('templates/accessErr'); 
}} 

    public function registered($year){ 
       if($this->accesscheck()){ 

        $this->gettable($year,"register"); 

    }else{ 
    $this->load->view('templates/accessErr'); 
}} 
    public function uncontacted($year){ 
         if($this->accesscheck()){ 
      $this->getTable($year,"uncontacted"); 

    }else{ 
    $this->load->view('templates/accessErr'); 
}} 
    public function unsearched($year){ 
         if($this->accesscheck()){ 
      $this->getTable($year,"unsearched"); 


    }else{ 
    $this->load->view('templates/accessErr'); 
}} 
    public function notfound($year){ 
           if($this->accesscheck()){ 

       $this->gettable($year,"notFound"); 


    }else{ 
    $this->load->view('templates/accessErr'); 
}} 
public function Paid($year){ 
    if($this->accessCheck()){ 

        $this->getTable($year,"Paid"); 


    }else{ 
    $this->load->view('templates/accessErr'); 
}} 
public function getProfile(){ 
    $id=$this->input->get('id'); 
    $data = $this->membermodel->getPrimaryInfo($id); 

    echo json_encode($data); 
} 
public function getTable($year,$list){ 
    $this->data1 = $this->membermodel->getYearList(); 
     if(in_array(array('alumSince'=>$year),$this->data1)){// think of a get around 
      $data['table'] = $this->membermodel->getTable($year,$list); 
      $data['year'] = $year; 
      $this->load->view('templates/header'); 
      $this->load->view('templates/menu'); 
      $this->load->view('members/fullList',$data); 
      $this->load->view('templates/footer'); 
     }else{ 
      $this->load->view('templates/header'); 
      $this->load->view('templates/badParam'); 
      $this->load->view('templates/footer'); 
     } 
} 


public function search(){ 

     if($this->session->userdata('privilege')){ 
     $this->load->view('templates/header'); 
     $this->load->view('templates/menu'); 
     $this->load->view('members/search'); 
     $this->load->view('templates/footer'); 

     } 
     else 
     $this->load->view('templates/accessErr'); 
    } 

    public function generate_result(){ 


     if($this->session->userdata('privilege')){ 
      $data = $this->membermodel->search(); 

         if($data){ 
          $this->load->view('templates/header'); 
          $this->load->view('templates/menu'); 
          $this->load->view('members/search_result',$data); 
          $this->load->view('templates/footer'); 
         } 



     }else{ 
      $this->load->view('templates/accessErr'); 
} 

} 

public function updateProfile(){ 
    if($this->accessCheck()){ 
     if($this->input->post('submit')){ 

      if($msg = $this->membermodel->updateProfile()){ 
       header('Refresh:2,url='.$_SERVER["HTTP_REFERER"]);//security issues here 
       echo $msg; 
      } 
     } 

    }else{ 
     $this->load->view('templates/accessErr'); 
    } 


} 

public function updateSearch(){ 
    if($this->accessCheck()){ 
     $alumid = $this->input->get('alumid'); 
     $search = $this->input->get('search'); 
     $result = $this->membermodel->updateSearch($alumid,$search); 
      echo $result; 
     } 
     else{ 
     $this->load->view('templates/accessErr'); 
    } 
} 
public function updateResponse(){ 
    if($this->accessCheck()){ 
     $alumid = $this->input->get('alumid'); 
     $response = $this->input->get('response'); 
     $result = $this->membermodel->updateResponse($alumid,$response); 
      echo $result; 
     } 
     else{ 
     $this->load->view('templates/accessErr'); 
    } 
} 
public function updatePayment(){ 
    if($this->accessCheck()){ 
      $alumid = $this->input->get('alumid'); 
      $dateofpayment = $this->input->get('dateofpayment'); 
      $referenceNo = $this->input->get('referenceNo'); 
      $paymentAmt = $this->input->get('paymentAmt'); 
      $remarks = $this->input->get('remarks'); 
      $result = $this->membermodel->updatePayment($alumid,$dateofpayment,$referenceNo,$paymentAmt,$remarks); 

       echo $result; 




    }else{ 
     $this->load->view('templates/accessErr'); 
    } 
} 
public function updateRegister(){ 
    if($this->accessCheck()){ 
      $register = $this->input->get('register'); 
      $alumid = $this->input->get('alumid'); 
      $result = $this->membermodel->updateRegister($alumid,$register); 

       echo $result; 




    }else{ 
     $this->load->view('templates/accessErr'); 
    } 
} 
public function addCallDetail(){ 
    $alumid = $this->input->get('alumid'); 
    date_default_timezone_set('Asia/Calcutta'); 
    $date = date('Y-m-d'); 
    $time = date('H:i:s'); 
    echo $this->membermodel->addCallDetail($alumid,$date,$time); 
} 

public function updateCall(){ 
     $remarks = $this->input->get('remarks'); 
     $nextdate = $this->input->get('nextdate'); 
     $nexttime = $this->input->get('nexttime'); 
     $callid = $this->input->get('callid'); 
     $alumid = $this->input->get('alumid'); 
     echo $this->membermodel->updateCall($remarks,$nextdate,$nexttime,$callid,$alumid); 

} 
public function updateMember(){ 
     $name = $this->input->get('name'); 
     $age = $this->input->get('age'); 
     $gender = $this->input->get('gender'); 
     $relationship = $this->input->get('relationship'); 
     $alumid = $this->input->get('alumid'); 
     echo $this->membermodel->updateMember($name,$age,$gender,$relationship,$alumid); 

} 
public function removeAccompaniant(){ 
     $memberid = $this->input->get('id'); 
     $alumid = $this->input->get('alumid'); 
     echo $this->membermodel->removeAccompaniant($memberid,$alumid); 

} 
public function updateRemark(){ 
    $remark = $this->input->get('remark'); 
    $alumid = $this->input->get('alumid'); 

    echo $this->membermodel->updateRemark($alumid,$remark); 
} 


public function getNetworkingSummary($year){ 

    $userid = $this->membermodel->getUserId(); 
    if($data = $this->membermodel->getNetworkingSummary($userid,$year)) 
     echo json_encode($data); 

     //echo json_encode($data['msg']="boo"); 
} 
public function getNotifications(){ 
    if($this->accessCheck()){ 
     $data['result'] = $this->membermodel->getNotifications(); 
     $this->load->view('templates/header'); 
     $this->load->view('templates/menu'); 
     $this->load->view('templates/dummyMember',$data); 
     $this->load->view('templates/footer'); 
    }else{ 
     $this->load->view('templates/accessErr'); 

    } 

} 
public function notificationStatus(){ 
    $id = $this->input->get('id'); 

    $this->membermodel->updateNotificationStatus($id); 

} 

} 
?> 
+0

如果您想知道錯誤是什麼,請檢查您的網絡服務器生成的'error_log'文件。獲取500內部服務器錯誤意味着您的代碼或服務器中的錯誤。可能從文件夾權限到錯誤代碼到各種各樣的東西,這就是爲什麼你必須檢查'error_log'。 – Prix 2014-09-04 22:14:48

+0

在靠近文件頂部的CI安裝根目錄中打開您的'index.php'文件,通過更改環境常量打開錯誤報告,然後重新加載頁面。 (您可能需要添加'ini_set('display_errors','on');'line。)。您應該會看到更詳細的錯誤消息。 – 2014-09-04 22:23:06

+0

@Prix,我看到錯誤日誌,它說我的文件中有一個語法錯誤,它表示意外的'['in'switch($ query-> row_array()['search']){「。但是在Windows上沒有這樣的錯誤。這是由於不同的PHP版本? – light94 2014-09-04 22:27:19

回答

1

誠如通過大獎賽,我檢查了我的錯誤日誌,發現問題是由於語法錯誤。 我正在使用函數數組解引用已在PHP 5.4.0中添加,但我的服務器運行PHP 5.2。

的解決方案是here

的解決方案工作。我不得不採取這種方法,而不是升級我的PHP版本,因爲服務器運行的是UBUNTU 12.04,它沒有PHP 5.4版本。