0

I debugging everything and the reason that return 500 Error comes from this part :

for($k=0;$k<=$i;$k++)
{
    $crr_id=$field1['TestId'][$k];
    $sql2="SELECT Frontname FROM apply.StudentsInfo WHERE TestId='$crr_id'";
    $query2=mssql_query($sql2);
    while( $row2 = mssql_fetch_assoc($query2)){
        $row2['Frontname']=iconv("windows-874","utf-8", $row2['Frontname']);
        echo $row2['Frontname'];
        if($row2['Frontname']==iconv("windows-874","utf-8", "เด็กชาย") 
                   || $row2['Frontname']==iconv("windows-874","utf-8", "นาย"))
        {
            $male++;
        }
        else if($row2['Frontname']==iconv("windows-874","utf-8", "เด็กหญิง") 
                 || $row2['Frontname']==iconv("windows-874","utf-8", "นางสาว"))
        {
            $female++;
        }
    }
    mssql_free_result($query2); 
}

The problem is PHP gets data from MS SQL (data received prove by try to echo it) and go to if-else statement. For some reasons, it reject itself.

Solution that I tried: remove all iconv() functions. but doesn't work.

slavoo
  • 5,798
  • 64
  • 37
  • 39
r4yr1ffy
  • 135
  • 1
  • 2
  • 8
  • 1
    "500 Internal Server Error" (or a blank page) means your script is throwing an error but PHP is configured to hide it from you. You need to fix it ASAP because coding without the aid of error messages is hard. As quick start, you can set the `error_reporting` and `display_errors` directives in your computer's system-wide `php.ini` file ([details here](http://stackoverflow.com/a/5680885/13508)). Errors thumb rule: show in development, log in production. – Álvaro González Jan 24 '17 at 08:13
  • Or just look at the error log. – Don't Panic Jan 24 '17 at 09:30

0 Answers0