我正在开发安卓应用程序,在这个应用程序中,一个带有文本检索的列表视图来自服务器,源代码在这里,源链接。这是我的php代码
<?php
require_once("dbConnect.php");
$sql = "SELECT image,fullname,location from uploadfinding";
$res = mysqli_query($conn,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result, array(
"image"=>$row[0],
"fullname"=>$row[1],
"location"=>$row[2]));
echo " over";
}
echo json_encode($result);
mysqli_close($conn);
?>这是我的json回应
Connected successfully over over over[{"image":myurl\/uploadfinding\/uploads\/2016-04-25 06:38:051461584281226.jpg","fullname":"adi","location":"fgh"},{"image":myurl\/uploadfinding\/uploads\/2016-04-25 06:38:201461584297706.jpg","fullname":"adi2","location":"fgh2"},{"image":myurl\/uploadfinding\/uploads\/2016-04-25 06:45:441461584739479.jpg","fullname":"adi23","location":"cn"}]我尝试了很多东西,但结果是none.the完全源代码在这里:
我不会在这里发布任何java文件,因为这个示例对这个url很好:
http://api.androidhive.info/json/movies.json但当我用我的网址代替这个:
http://myurl/PhotoUpload/getAllImages.php它只返回空活动。
发布于 2016-05-18 10:53:19
尝尝这个
<?php
header("content-type:application/json");
require_once("dbConnect.php");
$sql = "SELECT x1,x2,x3 from table_name";
$res = mysqli_query($conn,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result, array(
"x1"=>$row["x1"],
"x2"=>$row['x2'],
"x3"=>$row["x3"]));
echo " over";
}
echo json_encode($result);
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($result));
fclose($fp);
mysqli_close($conn);
?>将url "http://myurl/PhotoUpload/getAllImages.php“替换为"http://myurl/PhotoUpload/results.json”
发布于 2016-05-02 05:52:57
为了澄清:在您的应用程序中,您可以简单地将模拟器称为
“‘localhost”或127.0.0.1。
或
如果您正在使用真正的设备运行,请传递正确的url,如
编辑:
试着比较你的网址,
myurl/上载查找/上载/2016-04-25 06:38:051461584281226.jpg“
使用
在您的响应中,"双引号在图像标记前面丢失了。
传递图像链接,
"your_link“
https://stackoverflow.com/questions/36975668
复制相似问题