JSON decode error

`$db = new Database();
$data = array();
$getYear = $db->getRows("SELECT * FROM `users`");

foreach ($getYear as $row){
    $data[] = array(
        'ID' => $row['id'],
        'Person Name' => $row['id']
    );
};
echo json_encode($data);

This is my output

[{"Year":"47978186","ID":"47978186"},{"Year":"47978187","ID":"47978187"},{"Year":"47978188","ID":"47978188"},{"Year":"47978189","ID":"47978189"},{"Year":"47978190","ID":"47978190"},{"Year":"47978191","ID":"47978191"},{"Year":"47978192","ID":"47978192"},{"Year":"47978193","ID":"47978193"},{"Year":"47978194","ID":"47978194"},{"Year":"47978195","ID":"47978195"},{"Year":"47978196","ID":"47978196"},{"Year":"47978197","ID":"47978197"},{"Year":"47978198","ID":"47978198"}]

But I keep getting

C:\wamp64\www\project\content\users.php:67:int 4

$jsonData = file_get_contents("…/scripts/getUsers.php");
$json = json_decode($jsonData, true);
$error = json_last_error();
var_dump($error);

The script you posted can not generate the output you posted, please update the post with updated code/output.

Sponsor our Newsletter | Privacy Policy | Terms of Service