2016-04-26 69 views
0

我試圖將數據插入到數據庫中的數據庫中的數據後返回500內部服務器錯誤,但我在控制檯獲得500內部服務器錯誤消息,服務器試圖插入使用笨

我試圖去做?

我試圖使用jquery與此代碼發送形式的數據,

function submit_form (form) { 
    var url  = $('form#my_form').attr("action"); 
    var formData = {}; 
    $('form#my_form').find("input[name]").each(function (index, node) { 
    formData[node.name] = node.value; 
    }); 
    $.post(url, formData).done(function (data) { 
    swal(data); 
    }); 
} 

從在codeigniter控制器,這種方法是負責接收已發送的數據,

public function add() { 
    $data = $this->_accept(); 
    $result = $this->company_model->add($data); 
    echo $result; 
    } 

接收數據很好,但是當我將它傳遞給模型時,

public function add ($data) { 
    $result = $this->db->insert($this->table_name, $data); 
    return $result; 
    } 

並試圖將數據插入數據庫,一條消息返回500內部服務器錯誤,我對解決方案沒有任何想法,我正在嘗試任何事情,直到我不知道爲止。

任何人有想法?

+0

啓用$配置[ 'log_threshold'](水平ERROR),然後重新運行這種情況下。之後,您需要檢查應用程序/日誌中的錯誤日誌以查看問題。 – Vuong

回答

0

可能有幾個原因錯誤

1. Please check your table_name that you are passing.i.e. $this->table_name... 
    2. Check your data, which you are inserting, means string/characters must be in single quotes and numerical in without quotes. 
    3. Check your database table fields and inserting array values. Inserting array values must be respective to the database table fields. 
+0

我已經這樣做了,因爲它沒有使用jquery。 – Fil