Java can';t将localhost mysql数据库与android应用程序连接:解析数据org.json.JSONException时出错
我正在使用JSON和php脚本从mysql数据库获取数据Java can';t将localhost mysql数据库与android应用程序连接:解析数据org.json.JSONException时出错,java,php,android,mysql,json,Java,Php,Android,Mysql,Json,我正在使用JSON和php脚本从mysql数据库获取数据 try { response = CustomHttpClient.executeHttpPost( "http://192.168.1.100:61896/JsonDemoDatabase/src/jsonscript.php", postParam
try
{
response = CustomHttpClient.executeHttpPost(
"http://192.168.1.100:61896/JsonDemoDatabase/src/jsonscript.php",
postParameters);
String result = response.toString();
try
{
returnString = "";
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++)
{
JSONObject json_data = jArray.getJSONObject(i);
pass = json_data.getString("Password");
if(pass.equals(password.getText().toString()))
{
//Get an output to the screen
tv.setVisibility(1);
returnString += "Login Successfull";
}
else
{
tv.setVisibility(1);
returnString += "Login Fail";
}
}
}
catch(JSONException e)
{
Log.e("log_tag", "Error parsing data "+e.toString());
}
试试看
{
响应=CustomHttpClient.executeHttpPost(
"http://192.168.1.100:61896/JsonDemoDatabase/src/jsonscript.php",
后参数);
字符串结果=response.toString();
尝试
{
returnString=“”;
JSONArray jArray=新JSONArray(结果);
对于(int i=0;iDid)您是否检查了您的响应数据?特别是,response
上的toString()
可能没有提供您期望的JSON。