Androidデバイスのコードは次のとおりです。
public JSONObject getJSONFromUrl(String url, List<NameValuePair> params) {
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
json = sb.toString();
Log.e("JSON", json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
PHPサーバーのコードは次のとおりです。
$name = $_POST['name'];
$email= $_POST['email'];
$password = $_POST['password'];
$user = $db->storeUser($name, $email, $password);
if($user){
echo json_encode($response). "User Stored Successfully";
}
else{
echo json_encode($response). "Error Occured in Registration";
}
ここで、storeUserは次のとおりです。
public function storeUser($name, $email, $password) {
$result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email','$encrypted_password', '$salt', NOW())");
}
プロセスは機能し、Androidデバイスにメッセージを送り返しますが、詳細はMySQLデータベースに挿入されませんか?
私が欲しいのは、Androidデバイスから詳細を投稿し、サーバー上のMySQLデータベースに挿入することだけです。
なぜこれが引き起こされているのか誰もが知っています、私は何を間違っているのですか?