title: PHP - conditional statement not working properly
body: <p>I'm working in PHP and JSON at API for my mobile application. I tried to write a registration module, but a part of my conditional statements don't work as expected.</p>
  
  <p><strong>If statement 1 :</strong></p>
  
  <pre><code>if(!isset($_GET['username']) || !isset($_GET['password']) || !isset($_GET['imei']) || !isset($_GET['imie']) || !isset($_GET['nazwisko']) || !isset($_GET['email']) || !isset($_GET['zgoda']) || !isset($_GET['telefon']) || !isset($_GET['zgoda2']) || !isset($_GET['kraj']));
   {
    $returning = array('error' =&gt; 'Invalid query');
    echo json_encode($returning);
    break;
   }
  </code></pre>
  
  <p>It should give an error, when there is an argument missing, but it is giving an error always.</p>
  
  <p>My query :</p>
  
  <p><code>username=konrad12&amp;password=xxx&amp;imei=000000000000000&amp;nazwisko=Potter&amp;imie=Ronald&amp;email=xxx@xxx.pl&amp;zgoda=1&amp;telefon=000&amp;zgoda2=1&amp;kraj=Poland</code></p>
  
  <p><strong>If statement 2 :</strong></p>
  
  <pre><code> if(strlen($c) != 15 || !validEmail($f) || strlen($g) != 1 || strlen($i) != 1 || wez_id_kraju($j) == 0)
   {
    $returning = array('error' =&gt; 'Invalid query');
    echo json_encode($returning);
    break;
   } 
  </code></pre>
  
  <p>It should give an error, when var values are incorrect, but it is giving an error always.</p>
  
  <p>My variables :</p>
  
  <pre><code> $z = mysql_real_escape_string($_GET['username']);
   $b = mysql_real_escape_string($_GET['password']);
   $c = mysql_real_escape_string($_GET['imei']);
   $d = mysql_real_escape_string($_GET['nazwisko']);
   $e = mysql_real_escape_string($_GET['imie']);
   $f = mysql_real_escape_string($_GET['email']);
   $g = mysql_real_escape_string($_GET['zgoda']);
   $h = mysql_real_escape_string($_GET['telefon']);
   $i = mysql_real_escape_string($_GET['zgoda2']);
   $j = mysql_real_escape_string($_GET['kraj']);
  </code></pre>
  
  <p><strong>If statement 3 :</strong></p>
  
  <pre><code> if($g != 0 or 1 || $i != 0 or 1)
   {
    $returning = array('error' =&gt; 'Invalid query');
    echo json_encode($returning);
    break;
   } 
  </code></pre>
  
  <p>It should give an error, when value of $g or $i isn't 1 or 0, but it is giving an error always.</p>
  
  <p>Please help me, I tried a lot of things, but I can't find a solution</p>
  
  <p>@Edit :</p>
  
  <p>My valid email function :</p>
  
  <pre><code>    function validEmail($email)
      {
         $isValid = true;
         $atIndex = strrpos($email, "@");
         if (is_bool($atIndex) &amp;&amp; !$atIndex)
         {
            $isValid = false;
         }
         else
         {
            $domain = substr($email, $atIndex+1);
            $local = substr($email, 0, $atIndex);
            $localLen = strlen($local);
            $domainLen = strlen($domain);
            if ($localLen &lt; 1 || $localLen &gt; 64)
            {
               // local part length exceeded
               $isValid = false;
            }
            else if ($domainLen &lt; 1 || $domainLen &gt; 255)
            {
               // domain part length exceeded
               $isValid = false;
            }
            else if ($local[0] == '.' || $local[$localLen-1] == '.')
            {
               // local part starts or ends with '.'
               $isValid = false;
            }
            else if (preg_match('/\\.\\./', $local))
            {
               // local part has two consecutive dots
               $isValid = false;
            }
            else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
            {
               // character not valid in domain part
               $isValid = false;
            }
            else if (preg_match('/\\.\\./', $domain))
            {
               // domain part has two consecutive dots
               $isValid = false;
            }
            else if
      (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&amp;`_=\\/$\'*+?^{}|~.-])+$/',
                       str_replace("\\\\","",$local)))
            {
               // character not valid in local part unless 
               // local part is quoted
               if (!preg_match('/^"(\\\\"|[^"])+"$/',
                   str_replace("\\\\","",$local)))
               {
                  $isValid = false;
               }
            }
            if ($isValid &amp;&amp; !(checkdnsrr($domain,"MX") || 
       ↪checkdnsrr($domain,"A")))
            {
               // domain not found in DNS
               $isValid = false;
            }
  // I add that text ...
        mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD);
        mysql_select_db(DB_BASE);
        $q = "SELECT * FROM `system_domeny`";
        $a = mysql_query($q);
        while($wynik = mysql_fetch_array($a))
        {
         if($domena == $wynik[1]) $isValid = false;
        }
  // ...
         }
         return $isValid;
      }
  </code></pre>