android中通过php从数据库中获取数据的http请求,与使用浏览器的结果不同

xxb16uws  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(228)

我正在开发一个android应用程序,使用php与服务器交互。我使用的是免费服务器,当我将php从本地移动到服务器时,发生了一些事情。
这是使用电话的结果:我在logcat中输出结果。

Log.d(TAG, "RESULT: " + result);

   D/GetNoteBackupsSummary: RESULT: <br /> 
   System.err: org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONArray

为什么我会 <br /> 结果呢?
从浏览器输出:

[{"id":"1","title":"nznnznss","content":"kzkzkzkzkz","date":"2018-10-06 23:02:50","backup_time":"2018-10-07 02:48:10"},
 {"id":"2","title":"nznzksks","content":"nsnsnnsksks","date":"2018-10-06 23:02:45","backup_time":"2018-10-07 02:48:10"}, 
  {"id":"3","title":"jzjsjsj","content":"nznzkzkzkz","date":"2018-10-06 23:02:40","backup_time":"2018-10-07 02:48:10"}, 
  {"id":"4","title":"bsjsjsj ","content":"jsjsksk ","date":"2018-10-06 23:02:35","backup_time":"2018-10-07 02:48:10"}]

这是php代码:

session_start();

// $user_email = $_POST["user_email"];
// $time = $_POST["backup_time"];

$time = "2018-10-07 02:48:10";
$user_email = "ccc@ccc";

if (!$con) {
    echo "Error: " . mysqli_connect_error();
    exit();
}
$result = new \stdClass();

$out_put = array();
$table_name = getBackupUserTableName($user_email);
$sql = "SELECT * FROM ".$table_name." WHERE backup_time = '".$time."'";
if($query = mysqli_query($con, $sql)){
    while ($row = mysqli_fetch_assoc($query))
    {
        array_push($out_put, $row);
    }
    print json_encode($out_put);
}else{
    $result -> status = false;
    $result -> error = mysqli_error($con);
    print json_encode($result);
}

mysqli_close ($con);

它在当地很管用。谢谢你的帮助!谢谢!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题