0

When I do this var answer = JSON.parse(xhr.response); I get an error Unexpected token a in JSON. PHP:

$from = $_POST['from'];
    $q = mysql_query("SELECT * FROM puzzles LIMIT $from,1");

    while(($row=mysql_fetch_assoc($q))!=false){
     $result = array('description' => $row['description'], 'id' => $row['id']);
     echo json_encode($result);
user7103883
  • 87
  • 1
  • 7
  • Put a print_r() or var_dump() on $result and check what is the content in it? – Mayank Pandeyz Apr 02 '17 at 09:55
  • @MayankPandeyz, {"description":"\u0422\u0440\u0438 \u043a\u0443\u0440\u0438\u0446\u044b \u0437\u0430 \u0442\u0440\u0438 \u0434\u043d\u044f \u043d\u0435\u0441\u0443\u0442 \u0442\u0440\u0438 \u044f\u0439\u0446\u0430. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0438\u0446 \u0441\u043d\u0435\u0441\u0443\u0442 12 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043a\u0443\u0440\u0435\u0439 \u0437\u0430 12 \u0434\u043d\u0435\u0439?","id":"7"}array(2) { ["load"]=> string(4) "true" ["from"]=> string(1) "6" } – user7103883 Apr 02 '17 at 11:34
  • do you know [why you need immediately to stop using mysql_* functions?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – hassan Apr 02 '17 at 12:01

0 Answers0