I have got data from mysql in php, and i want to send it to typescript using JSON. but when load the php page. nothing showed in the screen. It always shows a blank page.
$select ="SELECT * from `filiere`";
$run = mysqli_query($connect, $select);
$temp = array();
while($row=mysqli_fetch_row($run)) {
$temp[] = $row;
}
echo json_encode($temp);
from the code, it should show the data in json format.
what it is the problem?
In PHP, an unexpeted blank page usually means some kind of error + error reporting turned off.
Try to turn error reporting on
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(E_ALL);
EDIT #1: Based on the comments, it seems that json_encode()
fails, so returns false
(echoing false
will result in a blank page).
The json_last_error()
and/or json_last_error_msg()
functions should be used to find the error.
EDIT #2: The first argument of json_encode()
must hold only UTF-8 encoded strings.
I think i've understood where is my error. You are all right. i have some data with frensh letters like ('é', 'ù'..). I think that was the problem.
Thank you all