0

I am verifying a user (email address and password) in database and and echo the result.

if($num_rows == 1)
{
    $usertypeid = mysql_fetch_array($query_result);
    echo $usertypeid[0];
}
else
{
    echo "invalid_user";
}

When i test it on a normal browser it prints exactly what i want. When I do http request from android, it returns the string correct. But it has something garbage value at first byte I guess which is not visible though.

HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
strResult = EntityUtils.toString(httpEntity);

Then I am comparing strResult with a final string and check if it is not a failure.

if (!strResult.equals(Konstant.HTTP_RESULT_SIGNIN_FAILURE))

So, when strResult is actually "invalid_user" the condition should not pass. But it passes.

String value of HTTP Response

Final String value

If i use "endsWith()" instead of "equals()", it works fine. or If i use substring() to eliminate first byte and then use equals, it works fine.

Can anyone please help me what's happening here?

Karthik Andhamil
  • 838
  • 1
  • 12
  • 22

1 Answers1

1

You should encode the file as UTF-8 without BOM.

On Notepad++ you can do it by clicking the "Encoding" menu and then click the "Convert to UTF-8 (without BOM)" option.

tato.rodrigo
  • 2,503
  • 19
  • 25