php - Unexpected end of JSON input at JSON.parse
795
I made my RESTful mysql backend everything is good except that my feteched query has problem.I mean ,it show me nothing when my returned json is more than 2 objects. I'm working with ionic3 / http.
my select.php:
$sql = "SELECT * FROM products ORDER BY id";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$data = array() ;
while($row = $result->fetch_assoc()) {
$data[] = $row;
}
echo json_encode($data);
} else {
echo "0";
}
my service file in ionic:
getProducts(){
return this.http.get("http://localhost/api/products/select.php")
.map(res=>{
this.checkMe = res;
if(this.checkMe._body !== "0"){
return res.json()
}
} );
}
I realy need your help. Thank you all.
Answer
Solution:
have you tried to do ..
Answer
Solution:
I had html tag into one of me fields in the MySQL that stops the json_encode() operation.
Thanks you all ??