2016-10-20 3 views
1

を私はデータベースにデータをアップロードするには、このコードを持っている私は、ログにこれを取得するので、私はデータを持って知っているAsyncHttpResponseHandlerは、送信のparamsのために未定義取得; RequestParams、アンドロイド、ジャワ、PHP

RequestParams params = new RequestParams(); 
//prgDialog.show(); 
params.put("usersJSON", controller.getAllAnswerSheet()); 
System.out.println("onSuccess getAllAnswerSheet" + controller.numberOfRows("answer_sheet_tbl")); 
System.out.println("onSuccess getAllAnswerSheet" + controller.getAllAnswerSheet()); 
// Make Http call to updatesyncsts.php with JSON parameter which has Sync statuses of Users 
client.post("http://127.0.0.1/qna/process/uploadanswersheet.php", params, new AsyncHttpResponseHandler() { 

[{ 
    "answer": [{ 
     "sysid": "1", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "1", 
     "status": "active" 
    }, { 
     "sysid": "2", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "2", 
     "status": "active" 
    }, { 
     "sysid": "3", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "3", 
     "status": "active" 
    }, { 
     "sysid": "4", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "4", 
     "status": "active" 
    }, { 
     "sysid": "5", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "5", 
     "status": "active" 
    }, { 
     "sysid": "6", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "6", 
     "status": "active" 
    }, { 
     "sysid": "7", 
     "surveyid": "1", 
     "questionid": "0", 
     "answerid": "", 
     "householdid": "7", 
     "status": "active" 
    }, { 
     "sysid": "8", 
     "surveyid": "1", 
     "questionid": "1", 
     "answerid": "aklan", 
     "householdid": "8", 
     "status": "active" 
    }, { 
     "sysid": "9", 
     "surveyid": "1", 
     "questionid": "2", 
     "answerid": "kalibo", 
     "householdid": "9", 
     "status": "active" 
    }, { 
     "sysid": "10", 
     "surveyid": "1", 
     "questionid": "3", 
     "answerid": "7", 
     "householdid": "10", 
     "status": "active" 
    }, { 
     "sysid": "11", 
     "surveyid": "1", 
     "questionid": "3", 
     "answerid": "7", 
     "householdid": "11", 
     "status": "active" 
    }, { 
     "sysid": "12", 
     "surveyid": "1", 
     "questionid": "3", 
     "answerid": "7", 
     "householdid": "12", 
     "status": "active" 
    }, { 
     "sysid": "13", 
     "surveyid": "1", 
     "questionid": "6", 
     "answerid": "three", 
     "householdid": "13", 
     "status": "active" 
    }, { 
     "sysid": "14", 
     "surveyid": "1", 
     "questionid": "6", 
     "answerid": "three", 
     "householdid": "14", 
     "status": "active" 
    }, { 
     "sysid": "15", 
     "surveyid": "1", 
     "questionid": "7", 
     "answerid": "patwo", 
     "householdid": "15", 
     "status": "active" 
    }, { 
     "sysid": "16", 
     "surveyid": "1", 
     "questionid": "7", 
     "answerid": "pathree", 
     "householdid": "16", 
     "status": "active" 
    }, { 
     "sysid": "17", 
     "surveyid": "1", 
     "questionid": "7", 
     "answerid": "pathree", 
     "householdid": "17", 
     "status": "active" 
    }], 
    "survey": [{ 
     "sysid": "17", 
     "householdnum": "74", 
     "barangay": "manila", 
     "headfname": "martin", 
     "headmname": "", 
     "headlname": "manalo", 
     "headsuffix": "", 
     "status": "active" 
    }] 
}] 

私の問題は私のuploadanswersheet.phpページにあります。Undefined index: usersJSON意味paramsでデータを送信できませんでした。

これはuploadanswersheet.phpで私のコードです:

//Get JSON posted by Android Application 
$json = $_POST["usersJSON"]; 
//Remove Slashes 
$json = json_decode(stripslashes($json), true); 
//if (get_magic_quotes_gpc()){ 
//$json = stripslashes($json); 
//} 
+0

isset($ _ POST ['usersJSON'])){ echo "true";を使用してusersJSONがPHPに投稿されているかどうかを確認してください。 } else {echo "false"; } –

+0

* "AsyncHttpResponseHandlerはSendParamsのために未定義になっていますRequestParams android java php" * - それは文ですか?それとも、言葉の集まり? –

+0

@JagadeshaNHエラーが未定義であるため、投稿されていません。私はちょうどテキストを送信しようとし、PHPはそれを取得します。 paramsでJSONArrayを送信することを許可していないのですか?文字列に変換してからPHPで再度変換する必要がありますか? –

答えて

1

は、文字列にJSONに変換し、それを投稿してください。そしてサーバー側でJSONに戻す文字列を変換する

関連する問題