在PHP中为JSON赋值

时间:2014-03-20 09:08:28

标签: php json

我必须从DB

添加json值
$mysql_all_resultset = mysqli_query($con,  " SELECT drs.currentLatitude, drs.currentLongitude, dd.imei_number FROM device_owner_details dod, device_realtime_stats drs, device_details dd WHERE dod.name =  $name AND drs.deviceId = dod.deviceId AND dd.id = drs.deviceId ");

$rows_data = mysqli_fetch_row($mysql_all_resultset);

$device_details = array("imei_number" => $rows_data['imei_number'], "latitude" => $rows_data['currentLatitude'], "longitude" => $rows_data['currentLongitude']);


$response = json_encode($device_details);

它产生解析错误,如何将值添加到JSON

1 个答案:

答案 0 :(得分:1)

使用单引号围绕$name ..