我遇到了问题,我无法弄清楚出了什么问题
这是我用json响应的php
//Verificado
if ($tag == 'reqSalasCheck') {
$sala = filter_input(INPUT_POST, 'sala');
$inicio = filter_input(INPUT_POST, 'inicio');
$fim = filter_input(INPUT_POST, 'fim');
$data = filter_input(INPUT_POST, 'dataFinal');
$dias = strftime('%A', strtotime($data));
$newDate = date("Y-m-d", strtotime($data));
$diaId = mysql_query("SELECT * FROM `ebspma_paad_ebspma`.`semana_dias` WHERE dia ='$dias'");
$diaRow = mysql_fetch_row($diaId)or die(mysql_error());
$Dias = $diaRow[0];
if ($Dias != null) {
$inicioId = mysql_query("SELECT `idtempo` FROM `ebspma_paad_ebspma`.`req_material_tempo` WHERE `inicio`='$inicio'");
$inicioRow = mysql_fetch_row($inicioId)or die(mysql_error());
$inicio = $inicioRow[0];
if ($inicio != null) {
$salaId = mysql_query("SELECT `idsala` FROM `ebspma_paad_ebspma`.`req_material_sala` WHERE `sala` = '$sala'");
$salaRow = mysql_fetch_row($salaId)or die(mysql_error());
$sala = $salaRow[0];
if ($sala != null) {
$fimId = mysql_query("SELECT `idtempo` FROM `ebspma_paad_ebspma`.`req_material_tempo` WHERE `fim`= '$fim'");
$fimRow = mysql_fetch_row($fimId)or die(mysql_error());
if ($fim != null) {
$checkIfOcupado = mysql_query("SELECT COUNT(id_dia) FROM `ebspma_paad_ebspma`. `sala_ocupacao` WHERE id_dia = '$Dias' AND id_sala= '$sala' AND id_tempo = '$inicio'");
$checkResult = mysql_fetch_row($checkIfOcupado) or die($checkIfOcupado . "<br/><br/>" . mysql_error());
$checkResultado = $checkResult[0];
if ($checkResultado > 0) {
$response["error"] = 2;
$response["error_msg"] = "Hora marcada no ano";
echo json_encode($response);
} else {
$checkIfReservado = mysql_query("SELECT COUNT(*) AS total FROM `ebspma_paad_ebspma`.`req_material_reserva`
WHERE `ebspma_paad_ebspma`.`req_material_reserva`.`idsala` = '$sala'
AND (((`req_material_reserva`.`idtempoInicio` BETWEEN '$inicio' AND '$fim') AND (`req_material_reserva`.`idTempoFim` BETWEEN '$inicio' AND '$fim'))
OR (`req_material_reserva`.`idtempoInicio` <= '$inicio' AND `req_material_reserva`.`idTempoFim` >= '$fim'))
AND `req_material_reserva`.`data` = '$newDate'");
$checkReserva = mysql_fetch_row($checkIfReservado) or die($checkIfReservado . "<br/><br/>" . mysql_error());
$checkReservado = $checkReserva[0];
if ($checkReservado > 0) {
$response["error"] = 2;
$response["error_msg"] = "Oops! Sala reservada";
echo json_encode($response);
} else {
$response["success"] = 1;
$response["message"] = "Sala disponível.";
echo json_encode($response);
}
}
}
}
}
}
}
这是我的android java,其中称为
private static final String KEY_MESSAGE = "message";
private static final String KEY_MESSAGE_ERROR = "error_msg";
JSONObject salasCheck = userFunctions.reqSalasCheck(sala, inicio, fim, dataReserva);
try {
String res = salasCheck.getString(KEY_SUCCESS);
Log.d("Mensagem", res);
String error = salasCheck.getString(KEY_ERROR);
Log.d("Mensagem", error);
if (Integer.parseInt(res) == 1) {
String messageOK = salasCheck.getString(KEY_MESSAGE);
但我收到此错误
解析数据时出错org.json.JSONException:字符0处的输入结束 org.json.JSONException:消息没有值
我的php定义了消息..