从服务器获取所有图像的代码。我正在保存的网址 我的服务器路径/目录中存在的图像到SQL数据库(名称:照片,列:id和图像)
<?php
$connection = mysqli_connect("localhost","webkuv1c_naman","naman","webkuv1c_android_api") or die("Error " . mysqli_error($connection));
$sql = "select image from photos";
$res = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result,array('url'=>$row['image']));
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
?>
我在点击API时得到以下回复:
{"result":[]}
这是图片路径/网址:http://webkunj.com/android_api/productUpload/0.png
答案 0 :(得分:0)
你已经把所有事情都做好了 只需替换
$connection = mysqli_connect("localhost","webkuv1c_naman","naman","webkuv1c_android_api") or die("Error " . mysqli_error($connection));
与
$con = mysqli_connect("localhost","webkuv1c_naman","naman","webkuv1c_android_api") or die("Error " . mysqli_error($con));