2012-06-30 3 views
2

나는이codeignitor 양식 유효성 검사 오류

$this->form_validation->set_rules("contact_name[]","Contact Name","required|max_length[25]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_title[]","Contact Title","required|max_length[25]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_main[]","Contact Main Number","required|max_length[45]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_direct[]","Contact Direct Number","required|max_length[45]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_cell[]","Contact Cell Number","required|max_length[45]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_primary","Primary","required|max_length[45]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_fax[]","Fax","required|max_length[105]|xss_clean|htmlspecialchars"); 
     $this->form_validation->set_rules("contact_email[]","Contact Email ID","required|max_length[105]|xss_clean|htmlspecialchars"); 

같은 규칙을 설정하고 있고 html로 내가이

array 
    'company' => string 'Sccc' (length=4) 
    'name' => string 'Ajay ccc' (length=8) 
    'address' => string 'ccsd' (length=4) 
    'city' => string 'City name' (length=9) 
    'state' => string '20' (length=2) 
    'zip' => string '665996555' (length=9) 
    'country' => string '6' (length=1) 
    'category' => string 'popular' (length=7) 
    'credit' => string '2566' (length=4) 
    'website' => string 'ccc' (length=3) 
    'primary_flag' => string '1' (length=1) 
    'discount' => string '0' (length=1) 
    'payment_terms' => string '6' (length=1) 
    'customerid' => string 'ccc' (length=3) 
    'notes' => string 'cc' (length=2) 
    'contact_name' => 
    array 
     0 => string 'Dileep' (length=6) 
     1 => string 'Dileep' (length=6) 
     2 => string 'Dileep' (length=6) 
     3 => string 'Dileep' (length=6) 
     4 => string 'Dileep' (length=6) 
     5 => string 'Dileep' (length=6) 
     6 => string 'Dileep' (length=6) 
     7 => string 'Dileep' (length=6) 
     8 => string 'Dileep' (length=6) 
    'contact_primary' => 
    array 
     0 => string 'true' (length=4) 
     1 => string 'false' (length=5) 
     2 => string 'false' (length=5) 
     3 => string 'false' (length=5) 
     4 => string 'false' (length=5) 
     5 => string 'false' (length=5) 
     6 => string 'false' (length=5) 
     7 => string 'false' (length=5) 
     8 => string 'false' (length=5) 
    'contact_title' => 
    array 
     0 => string 'Curio' (length=5) 
     1 => string 'Curio' (length=5) 
     2 => string 'Curio' (length=5) 
     3 => string 'Curio' (length=5) 
     4 => string 'Curio' (length=5) 
     5 => string 'Curio' (length=5) 
     6 => string 'Curio' (length=5) 
     7 => string 'Curio' (length=5) 
     8 => string 'Curio' (length=5) 
    'contact_main' => 
    array 
     0 => string '66558-66554-6665' (length=16) 
     1 => string '66558-66554-6665' (length=16) 
     2 => string '66558-66554-6665' (length=16) 
     3 => string '66558-66554-6665' (length=16) 
     4 => string '66558-66554-6665' (length=16) 
     5 => string '66558-66554-6665' (length=16) 
     6 => string '66558-66554-6665' (length=16) 
     7 => string '66558-66554-6665' (length=16) 
     8 => string '66558-66554-6665' (length=16) 
    'contact_direct' => 
    array 
     0 => string '5555-666-555' (length=12) 
     1 => string '5555-666-555' (length=12) 
     2 => string '5555-666-555' (length=12) 
     3 => string '5555-666-555' (length=12) 
     4 => string '5555-666-555' (length=12) 
     5 => string '5555-666-555' (length=12) 
     6 => string '5555-666-555' (length=12) 
     7 => string '5555-666-555' (length=12) 
     8 => string '5555-666-555' (length=12) 
    'contact_cell' => 
    array 
     0 => string '555-6654-555' (length=12) 
     1 => string '555-6654-555' (length=12) 
     2 => string '555-6654-555' (length=12) 
     3 => string '555-6654-555' (length=12) 
     4 => string '555-6654-555' (length=12) 
     5 => string '555-6654-555' (length=12) 
     6 => string '555-6654-555' (length=12) 
     7 => string '555-6654-555' (length=12) 
     8 => string '555-6654-555' (length=12) 
    'contact_fax' => 
    array 
     0 => string '996-5565-656' (length=12) 
     1 => string '996-5565-656' (length=12) 
     2 => string '996-5565-656' (length=12) 
     3 => string '996-5565-656' (length=12) 
     4 => string '996-5565-656' (length=12) 
     5 => string '996-5565-656' (length=12) 
     6 => string '996-5565-656' (length=12) 
     7 => string '996-5565-656' (length=12) 
     8 => string '996-5565-656' (length=12) 
    'contact_email' => 
    array 
     0 => string '[email protected]' (length=20) 
     1 => string '[email protected]' (length=20) 
     2 => string '[email protected]' (length=20) 
     3 => string '[email protected]' (length=20) 
     4 => string '[email protected]' (length=20) 
     5 => string '[email protected]' (length=20) 
     6 => string '[email protected]' (length=20) 
     7 => string '[email protected]' (length=20) 
     8 => string '[email protected]' (length=20) 
    'userfile2' => string '' (length=0) 
    'contact_log' => 
    array 
     0 => string 'Waiting for the release....' (length=27) 
    'contact_time' => 
    array 
     0 => string '6/30/12' (length=7) 
    'contact_duedate' => 
    array 
     0 => string '12/01/2012' (length=10) 
같은 것을 얻을 것이다 게시 후 =>

<input type="text" name="contact_name[]" value="Dileep" class="t_contact_name"> 
    //and some others too as name as array 

입니다

하지만 양식 유효성 검사를 실행하면 오류가 발생합니다.

A PHP Error was encountered 

Severity: Warning 

Message: mb_strlen() expects parameter 1 to be string, array given 

Filename: libraries/Form_validation.php 

Line Number: 1003 
A PHP Error was encountered 

Severity: Warning 

Message: htmlspecialchars() expects parameter 1 to be string, array given 

Filename: libraries/Form_validation.php 

Line Number: 619 

무엇이 진짜 문제인가, 내가 뭘 잘못하고있는가 ??

도와주세요. 사전에

감사합니다.

편집

입력 이름 난 배열로 필드 이름을 사용할 필요가 values.So 같은 종류보다가, 배열되어 있는지 확인하십시오.

(코드 명에 따라) 폼 유효성 검증은 containsng 필드 이름이있는 폼을 배열로 유효성을 검사 할 수 있습니다.

+0

그것은 오류 메시지로 작성되었습니다 –

+0

@DamienPirsy 오류를 알고, 오류를 닫으려고합니다. – Red

답변

2

귀하의 입력은 배열로 구성되며, max_lengthhtmlspecialchars은 단일 문자열을 사용해야합니다.

값만 사용 입력이 유형이있다 :

<input type="text" name="contact_name" value="Dileep" class="t_contact_name"> 

입력에 배열 a를 전술 한 기능을 사용하지 않는해야한다.

+0

Nop, 더 많은 값이 있습니다 .. 배열을 확인하십시오. – Red

+0

그런 경우이 기능을 사용할 수 없습니다. 자체 유효성 검사 기능을 만듭니다. –

+0

CI는'폼 검증 클래스는 필드 이름으로 배열 사용을 지원합니다' – Red