왜 코드가 작동하지 않는지 알 수 없으므로 json으로 인코딩해야합니까? 내가 안드로이드 스튜디오에서 응용 프로그램에서이 PHP 코드 링크를 호출 의하지 작업 및 디스플레이 오류 메시지가,이 코드를 표시합니다 같은 jsonlint 웹 사이트에 디스플레이도json parse error on line 1 : < html >< body >
<html> <body> < script type = "text/javascript"
src = "/aes.js" > < /script><script>function toNumbers(d){var e=[];d.replace(/ (..)/g,
function(d) {
e.push(parseInt(d, 16))
});
return e
}
function toHex() {
for (var d = [], d = 1 == arguments.length && arguments[0].constructor == Array ? arguments[0] : arguments, e = "", f = 0; f < d.length; f++) e += (16 > d[f] ? "0" : "") + d[f].toString(16);
return e.toLowerCase()
}
var a = toNumbers("f655ba9d09a112d4968c63579db590b4"),
b = toNumbers("98344c2eee86c3994890592585b49f80"),
c = toNumbers("fafd97787619720460a70e34d00aedb4");
document.cookie = "__test=" + toHex(slowAES.decrypt(c, 2, a, b)) + "; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";
location.href = "http://gmarket.byethost5.com/json_getS.php?i=2";
를 위의 테스트는 PHP URL 및이 오류를 반환 할 때 :
라인 101 23,516,해석 에러 : < HTML> < body> <^"STRING ' 'NUMBER ','NULL '을 기대'TRUE ','FALSE ','{ ','[ ' , '정의되지 않음')
이 PHP를 링크 : http://gmarket.byethost5.com/json_getS.php
이 PHP 코드는 내가 사용 : 귀하의 JSON이 올바른지
<?php
$host= "sql201.byethost5.com";
$user = "xxxxxxx";
$pass = "xxxxxxx";
$db = "xxxxxxx";
$sql="select * from customer";
$con = mysqli_connect($host,$user,$pass,$db);
$result= mysqli_query($con,$sql);
$response = array();
while ($row = mysqli_fetch_array($result))
{
array_push($response,array("name"=>$row[0],"phone"=>$row[1]));
}
echo json_encode(array("customers"=>$response));
mysqli_close($con);
?>
URL은 json을 반환합니다. 문제는 Android 코드에있는 것처럼 보입니다 – Jens
'$ response = array(); 동안 ($ 행 = mysqli_fetch_array ($ 결과)) { $ 응답 [ '고객 [= 어레이 ("이름"=> $ 행 [0], "전화"=> $ 행 [1]); } echo json_encode ($ response); ' –