-1

I am trying to get JSON response from server but it's giving me

Parse error: syntax error, unexpected end of file in localhost\tourist\getPlaces.php on line 37

my init.php is working.

      <?php
require "init.php";

function getCategories(){
   // $db = new DbConnect();
    // array for json response
    $response = array();
    $response["places"] = array();

    // Mysql select query
    $result = mysql_query("SELECT * FROM places");
    if($result === FALSE) {
    die(mysql_error("error message for the user")); 

    while($row = mysql_fetch_assoc($result)){
        // temporary array to create single category
        $tmp = array();
        $tmp["id"] = $row['place_id'];
        $tmp["type"] = $row['type'];
        $tmp["thumbnail"] = $row['thumbnail'];
        $tmp["name"] = $row['name'];
        $tmp["city"] = $row['city'];
        $tmp["description"] = $row['description'];

        // push category to final json array
        array_push($response["places"], $tmp);
    }

    // keeping response header to json
    header('Content-Type: application/json');

    // echoing json result
    echo json_encode($response);
}

getCategories();
?>
SnareChops
  • 12,721
  • 9
  • 68
  • 90
Nukhba Arshad
  • 131
  • 2
  • 14

1 Answers1

2

You are missing a closing }.

Change

if($result === FALSE) {
    die(mysql_error("error message for the user")); 

To

if($result === FALSE) {
    die(mysql_error("error message for the user")); 
}
Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94
The Codesee
  • 3,628
  • 3
  • 32
  • 71