My PHP file does not execute the code in the else condition
<p>I have the following PHP code to serve my mobile app to insert some data into the database, however when it enters the else condition, it cannot send the mail to myself. I am quite sure my mail function is okay to send as I have moved the code to another PHP file to have a test, so why it does not work here? So I try if it can create a txt file, but no file occurs after the execution also.</p>

<pre><code>$result1 = mysql_query("SELECT COUNT(*) FROM Log") or die('Error! ' . mysql_error());
$query = "SELECT `Type` FROM `Log` WHERE `TechID` = '".$TechID."' ORDER BY LogTime DESC LIMIT 1";
$result2 = mysql_query($query) or die('Error! ' . mysql_error());

while($row1 = mysql_fetch_array($result1))
{
      $count = $row1['COUNT(*)'];
      if(mysql_num_rows($result2) &gt; 0)
          {
         while($row2 = mysql_fetch_array($result2))
             {
            if($row2['Type']!="Checkin")
                {
               $count = $count+1;
               $timezone = "Asia/Hong_Kong";
               if(function_exists('date_default_timezone_set')) 
                  date_default_timezone_set($timezone);
               $Time = date('Y/m/d H:i');
               mysql_query("INSERT INTO Log (LogID, TechID, ClientID, SiteID, LogTime, Type)
                    VALUES(".$count.", '".$TechID."', ".$ClientID.", ".$SiteID.", '".$Time."', 'Checkin')");
            }
                else
                {
                 mail('me@gmail.com', 'test mail', 'Just a test');
                 $content = "First folder"; 
                 $fp = fopen("C:/xampp/htdocs/Me/checking.txt","wb"); 
                 fwrite($fp,$content); 
                 fclose($fp);
            }
        }
     }
}
</code></pre>
