I've got a simple angular sql-php-json data fetching.
The code works until some record. Then it's trows an error. It works with 51 record, crashes with 52... Obviously I need all the data. :)
What am I missing? Thank you.
Console error:
{}
javascript:
var app = angular.module('myApp', []);
app.controller('Ctrl', function($scope, $http) {
$http.get(file)
.then(function (response) {$scope.names = response.data.records;},
function(error) {console.log(JSON.stringify(error));}
);
});
php:
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
include("connect.php");
$result = $conn->query("SELECT id, nev, cim, kapcsolat, bankszamlaszam, adoszam FROM szallito ORDER BY nev LIMIT 52");
$outp = "";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "") {$outp .= ",";}
$outp .= '{"id":"' . $rs["id"].'",';
$outp .= '"nev":"'. $rs["nev"].'",';
$outp .= '"cim":"'. $rs["cim"].'",';
$outp .= '"kapcsolat":"'. $rs["kapcsolat"].'",';
$outp .= '"bankszamlaszam":"'. $rs["bankszamlaszam"].'",';
$outp .= '"adoszam":"' . $rs["adoszam"].'"}';
}
$outp ='{"records":['.$outp.']}';
$conn->close();
echo($outp);
JSON.stringifyis spelled wrong - that's only prohibiting OP from logging the error - fix the typo and please post the actual error you're receiving from the server.