2013-12-17 3 views
0

나는 폼을 만들었고, 폼에서 수집 된 데이터를 mysql에서 만든 테이블로 보내기 위해 노력하고있다. 다음은이 데이터를 제출할 때 사용하려고 시도했지만 작동하지 않는 코드입니다. 테이블이 비어 있습니다?데이터가 데이터베이스로 전송되지 않습니까?

public function action_claimincentive() { 
    $this->template->content = View::factory('crm/uk/claim_incentive_form'); 
    $this->template->content->thanks = false; 
    $this->template->content->val = ''; 
    $this->template->content->post = ''; 

    if ($this->request->post('form')) { 
     $post = $this->request->post('form'); 

     $stmt = DB::query(Database::INSERT, 'INSERT INTO `claim_incentive_form_data` (`form_id`,`Claimant Name`, `Claimant Postcode`, `Purchase Order No.`, `Claimant Email Address`, `Storename`, `Storetown`, `Date of Sale`, `Date of Delivery`, `Tempur Acknowledgement No.`, `Tempur Product`) 
     VALUES (:claimantname, :claimantpostcode, :orderno, :email, :storename, :storetown, :dateofsale, :dateofdelivery, :acknowledgementno, :tempurproduct)'); 
     $stmt->param(':claimantname', $post['claimantname']); 
     $stmt->param(':claimantpostcode', $post['claimantpostcode']); 
     $stmt->param(':orderno', $post['orderno']); 
     $stmt->param(':email', $post['email']); 
     $stmt->param(':storename', $post['storename']); 
     $stmt->param(':storetown', $post['storetown']); 
     $stmt->param(':dateofsale', $post['dateofsale']); 
     $stmt->param(':dateofdelivery', $post['dateofdelivery']); 
     $stmt->param(':acknowledgementno', $post['acknowledgementno']); 
     $stmt->param(':tempurproduct', $post['tempurproduct']); 
     try { 
      $stmt->execute(); 
      $this->template->content->post = $post; 
      $this->template->content->thanks = true; 
     } catch (Exception $e) { 
      FB::error($e); 
     } 

    } 
} 
+0

bind_param 대신 PARAM의를 삽입 쿼리에 공급하고 또한 PARAM하지? – Viridis

답변

1

11 개의 열이 삽입되지만 10 개의 값만 있습니다. 나는 실수로 form_id을 포함하고 있다고 생각합니다.

0

열 불일치 오류, form_id 값은

$stmt = DB::query(Database::INSERT, 'INSERT INTO `claim_incentive_form_data` (`form_id`,`Claimant Name`, `Claimant Postcode`, `Purchase Order No.`, `Claimant Email Address`, `Storename`, `Storetown`, `Date of Sale`, `Date of Delivery`, `Tempur Acknowledgement No.`, `Tempur Product`) 
      VALUES (:form_id, :claimantname, :claimantpostcode, :orderno, :email, :storename, :storetown, :dateofsale, :dateofdelivery, :acknowledgementno, :tempurproduct)'); 

    $stmt->param(':form_id', $post['form_id']);// added form_id here, assumed you can replace by your value 
    $stmt->param(':claimantname', $post['claimantname']); 
    $stmt->param(':claimantpostcode', $post['claimantpostcode']); 
    $stmt->param(':orderno', $post['orderno']); 
    $stmt->param(':email', $post['email']); 
    $stmt->param(':storename', $post['storename']); 
    $stmt->param(':storetown', $post['storetown']); 
    $stmt->param(':dateofsale', $post['dateofsale']); 
    $stmt->param(':dateofdelivery', $post['dateofdelivery']); 
    $stmt->param(':acknowledgementno', $post['acknowledgementno']); 
    $stmt->param(':tempurproduct', $post['tempurproduct']); 
관련 문제