【发布时间】:2020-03-08 19:29:26
【问题描述】:
我在带有 PHP 和 MySQL 的 Android 中使用 JsonObjectRequest 并得到以下错误消息:
"JSONException: Value <br of type java.lang.String cannot be converted to JSONObject"
下面是我的 PHP 代码:
<?php
$month = $_POST['month'];
$connection = new mysqli("localhost","root","","Fubon");
$dateCheckSQLCommand = "select * from clockindata where Month(date)= $month ";
if ($result = $connection->query($dateCheckSQLCommand)) {
while ($row = $result->fetch_assoc()) {
echo json_encode($row);
}
$result->free();
}
$connection->close();
?>
有人说 br 是 html 中的换行符,而不是 Json 格式?
此外,我在 MySQL 的“日期”列中使用 DateTime 类型或 Timestamp 类型。我对 PHP 的 Json 响应如下所示。是关于 MySQL 设置还是 PHP 问题? :
{"account":"Fu","ssid":"Fu","date":"2019-11-14 00:00:00"},{"account":"Fu","ssid":"Fu","date":"2019-11-21 00:00:00"}
【问题讨论】:
-
我认为你需要先组合所有结果,然后再将其编码为 json 对象
-
可以分享一下移动端收到的android代码和json数据吗??
标签: php android mysql json jsonobjectrequest