db를 php와 연동하는중인데요 exception에러가 뜹니다.
public class HealthDataRequest extends StringRequest {
final static private String URL = "http:///logAdd.php";
private Map<String, String> map;
public HealthDataRequest(String userId, String title, String date, String time, String memo, String exerciseRoutine, Response.Listener<String> listener) {
super(Request.Method.POST, URL, listener, null);
map = new HashMap<>();
map.put("userId", userId);
map.put("title", title);
map.put("date", date);
map.put("time", time);
map.put("memo", memo);
map.put("routine", exerciseRoutine);
System.out.println("1번째 실행");
}
public HealthDataRequest(String date, Response.Listener<String> listener) {
super(Request.Method.POST, URL, listener, null);
map = new HashMap<>();
map.put("date", date);
System.out.println("2번째 실행");
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
return map;
}
}
똑같지만 db테이블에 맞춰 조금만 수정된 회원가입php파일에서는 잘 동작합니다. 그런데 왜 아래php파일에서는 Exception에러가 뜰까요...?
$connection = mysqli_connect("$host", "$dbUser", "$db_pw", "$db_name");
if (mysqli_connect_errno()) {
printf("Connection failed: %s \n", mysqli_connect_error());
exit();
}
else {
echo "MySql connection is completed";
}
$userId = $_POST["userId"];
$time = $_POST["time"];
$memo = $_POST["memo"];
$routine = $_POST["routine"];
$date = $_POST["date"];
$title = $_POST["title"];
// 위에 까지는 문제 없음!
$statement = mysqli_prepare($connection, "INSERT INTO healthlog VALUE (?,?,?,?,?,?)");
mysqli_stmt_bind_param($statement, "ssssss", $userId, $time, $memo, $routine, $date, $title);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
에러 코드는 다음과 같습니다.
I/System.out: MySql connection is completedasd123123123123123
W/System.err: org.json.JSONException: Value MySql of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:112)
at org.json.JSONObject.<init>(JSONObject.java:169)
at org.json.JSONObject.<init>(JSONObject.java:182)
at com.example.myhealthdiary.HealthLogAddScreen$1$1.onResponse(HealthLogAddScreen.java:75)
at com.example.myhealthdiary.HealthLogAddScreen$1$1.onResponse(HealthLogAddScreen.java:70)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:82)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:29)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:102)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)