0
인코딩 방식이 잘못 되었나요?JSON 인코딩 문제 PHP
<?php
include ("../includes/db_con.php");
$itemResults = mysql_query("SELECT `sold_for` FROM `items` WHERE `item_did_sell`='1'") or die();
$mIResults = mysql_query("SELECT `mi_price`, `mi_total_sold` FROM `misc_items` WHERE `mi_total_sold`>'1'") or die();
$donationResults = mysql_query("SELECT `amount` FROM `donations`") or die(mysql_error());
$total = 0;
$itemTotal = 0;
$mITotal = 0;
$donationTotal = 0;
while($row = mysql_fetch_assoc($itemResults)){
$itemTotal += $row['sold_for'];
$total += $itemTotal;
}
while($row = mysql_fetch_assoc($mIResults)){
$mITotal += ($row['mi_price'] * $row['mi_total_sold']);
$total += $mITotal;
}
while($row = mysql_fetch_assoc($donationResults)){
$donationTotal += $row['amount'];
$total += $donationTotal;
}
header("Content-Type: application/json");
$arr = array('items' => $itemTotal,'mitems' => $mITotal,'donations' => $donationTotal,'total' => $total);
$arr = json_encode($arr);
echo $arr;
include ("../includes/db_discon.php");
?>
스크립트 출력 : {"items":1000,"mitems":0,"donations":0,"total":1000}
은 (확인 된) 내 클라이언트 측 스크립트 내 JSON 어레이 내의 parase 오류가 존재에 의해 발생.
이 스크립트의 * 출력 *은 무엇입니까? – deceze
출력 :'{ "items": 1000, "mitems": 0, "donations": 0, "total": 1000}' – lampwins
출력 된 JSON이 완벽하게 유효합니다. – deceze