I get this JSON create file error called : "Malformed UTF-8 characters, possibly incorrectly encoded", if i try and make a file consisting of about 40 000 records.This happens at record 16669. If i limit the records to less than 16668, it is correct.The record in question is correct, i checked.
Any suggestions please?
Any suggestions please?
Code:
<?php
function get_data()
{
$connect = mysqli_connect("localhost","root","","registerdb");
$query = "SELECT * FROM users LIMIT 16700";
$result = mysqli_query($connect, $query);
$userdetails = array();
while($row = mysqli_fetch_array($result))
{
$userdetails['userdetails'][] = array(
'id' => $row["id"],
'idno' => $row["idno"],
'surname' => $row["surname"],
'firstname' => $row["firstname"]
);
}
return json_encode($userdetails);
}
$file_name = 'userdetails' . '.json';
if(file_put_contents($file_name, get_data()))
{
echo $file_name . ' file created';
}
else
{
echo json_last_error_msg();
echo 'there is an error';
}
?>
Comment