This code when run on our localhost works:
if($result){
if($tmp=$result->num_rows){
while($row = $result->fetch_assoc()) {
$myArray[] = $row;
}
echo json_encode($myArray[0]);
}
}
But, when it is run on the server (Godaddy Hosting) it reutrns a null value.
Check if you have any results in your database. If yes, then check if you have any non-ASCII caracters which makes your json_encode returning false, or encode them with utf8_encode :
while($row = $result->fetch_assoc()) {
$myArray[] = array_map('utf8_encode', $row);
}
You can also use json_last_error to help you debbuging.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.