Hello I'm kinda new to programming and I'm trying to use ajax and would like to get the value from this php, but can't get it to work
$userID = $_SESSION['id'];
$query = "SELECT * from ipcr where userID = '".$userID."'";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
    $current_id = $row['id'];
    $current_details = $row['details'];
    $current_dateCreated = $row['dateCreated'];
    $current_ipcrCode = $row['ipcrCode'];
    $current_employeeNumber = $row['employeeNumber'];
    $array = array(
        'id'=>$current_id,
        'details' => $current_details,
        'dateCreated' => $current_dateCreated,
        'ipcrCode' => $current_ipcrCode,
        'employeeNumber' => $current_employeeNumber
    );
    echo json_encode($array);
}
but i keep getting an error:
SyntaxError: Unexpected token < in JSON at position 173
and when i try to validate my json it gives this error
This is the actual output that the php echoed.
{"id":"21836","details":"Details here","dateCreated":"2018-08-01 14:25:28","ipcrCode":"22703","employeeNumber":"140010663"}
{"id":"21837","details":"details here","dateCreated":"2018-08-01 14:25:57","ipcrCode":"22703","employeeNumber":"140010663"}
Is there something wrong with the way I use json_encode? it seems that the format I echoed is wrong.
also this is how my script looks like
function get_ipcr() {
    var userID = <?php echo $_SESSION['id']; ?>;
    $.ajax({
        type: "POST",
        url: "../includes/php/load_ipcr.php",
        dataType: "json",
        success: function(results) {
            alert("success");
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
}
 
     
    