当我读取响应时,我总是从PHP收到错误消息:查询中缺少参数。 我知道PHP和查询是100%因为工作。只有这样才会发生。
Volley.class
JSONObject params = new JSONObject();
params.put("consulta", "UPDATE Usuarios SET Nombre='AAA' WHERE IdUsuario=1");
//All right
RequestFuture<JSONObject> future = RequestFuture.newFuture();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, URL", params, future, future); //request contains params with de sql sentence. Its well
VolleyS.getInstance(context).mRequestQueue.add(request);
JSONObject response = future.get(10, TimeUnit.SECONDS); //response contains the wrong error and the database isn't changed
if (response.getInt("success") == 0) correctoExterna = false;
else correctoExterna = true;
update.php
if (isset($_REQUEST['consulta'])){
$vConsulta= $_REQUEST['consulta'];
$result = mysql_query($vConsulta);
// mysqli_errno($db) != 0
if ($result)
{
$response["success"] = 1;
$response["message"] = "OK.";
echo json_encode($response);
myqli_commit($db);
mysqli_close($db);
}
else{
$response["success"] = 0;
$response["message"] = "ERROR :".mysqli_error($db);
echo json_encode($response);
mysqli_rollback($db);
mysqli_close($db);
}
}
else {
$response["success"] = 0;
$response["message"] = "ERROR, missing fields to insert";
echo json_encode($response);
mysqli_close($db);
}