2017-09-18 1 views
0

도와주세요 : 아래 코드가 $ error_message에서 오류를 반환하는 이유는 무엇입니까?SQL에서 두 번 열을 선택하십시오.

$_POST은 다음과 같습니다

Array 
(
    [preferred_district1] => Bubi 
    [preferred_district2] => Buhera 
    [gender] => Male 
    [user_first_name] => Kelvin 
    [user_last_name] => Tash 
    [mobile_number] => 77589655 
    [ec_number] => TAS4752 
    [user_email] => [email protected] 
    [user_password] => tash 
    [blank] => 
    [level_taught] => Primary - ECD 
    [current_province] => Harare 
    [current_district] => Goromonzi 
    [current_school] => SEKE 3 HIGH 
) 

내 코드는 여기에 있습니다 :

if (empty($error_message) && (isset($_POST["preferred_district1"]) || 
    isset($_POST["preferred_district2"])) && 
     (($_POST["preferred_district1"] || $_POST["preferred_district2"]) == 
     $_POST["current_district"])){ 
      $error_message = 'Invalid form input: Preferred District may not 
      be the same as Current District'; 
    } 

답변

0
if (empty($error_message) && (isset($_POST["preferred_district1"]) || 
    isset($_POST["preferred_district2"])) && 
    ((($_POST["preferred_district1"] == $_POST["current_district"]) 
     || ($_POST["preferred_district2"] == $_POST["current_district"]) 
     ) 
    ) 
) 
{ 
    $error_message = 'Invalid form input: Preferred District may not 
       be the same as Current District'; 
} 

or(||)으로 조건을 잘못 입력했습니다.

or(||)으로 두 개의 다른 변수를 확인하는 동안 여기에서했던 것처럼 개별적으로 확인해야합니다.

0

조건 리턴 사실, 당신은 preferred_district2 필드와 preferred_district1 필드가 있습니다. 아마도 문제는 또는 (||) 작업입니다. OR 연산 사이의 조건 중 하나가 참이면 true를 반환합니다.

관련 문제