为什么我一直有这个错误“语法错误,意外的文件结束”[关闭]

I keep having this error, and honestly I can't really figure it out.

    <?php
$servername="localhost"; //replace with database hostname 
$username="root"; //replace with database username 
$password=""; //replace with database password 
$dbname="mybd"; //replace with database name

//create connection
$conn = new mysqli($servername, $username, $password, $dbname);

    //check connection
    if($conn->connect_error){
        die("Connection failed: ".$conn->$connect_error);
    }


$sql = "SELECT rest.img,rest.rest_name,horario.desc_hor, rest.descp, rest.rest_id FROM rest, type, horario WHERE rest.type_id = type.type_id AND rest.id_hor = horario.id_hor AND rest.type_id=1";
$result = $conn->query($sql);
$cnt = $result->num_rows;

$json = array();

if($cnt>0){
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

            $row_array['rest_id'] = $row['rest_id'];
            $row_array['type_id'] = $row['type_id'];
            $row_array['rest_name'] = $row['rest_name'];
            $row_array['contacto'] = $row['contacto'];
            $row_array['id_hor'] = $row['id_hor'];
            $row_array['local'] = $row['local'];
            $row_array['descp'] = $row['descp'];
            $row_array['img'] = $row['img'];

            array_push($json_response,$row_array);

        }
    echo json_encode($json_response);
fclose($conn);
$conn->close();

?>

This PHP basically cannect to my mysql database and exports a table to JSON so I can pick it up with Android Studio.

The closing } is missing for your if statement.

You forget to close if($cnt>0){ condition

<?php
$servername="localhost"; //replace with database hostname 
$username="root"; //replace with database username 
$password=""; //replace with database password 
$dbname="mybd"; //replace with database name

//create connection
$conn = new mysqli($servername, $username, $password, $dbname);

    //check connection
    if($conn->connect_error){
        die("Connection failed: ".$conn->$connect_error);
    }


$sql = "SELECT rest.img,rest.rest_name,horario.desc_hor, rest.descp, rest.rest_id FROM rest, type, horario WHERE rest.type_id = type.type_id AND rest.id_hor = horario.id_hor AND rest.type_id=1";
$result = $conn->query($sql);
$cnt = $result->num_rows;

$json = array();

if($cnt>0){
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

            $row_array['rest_id'] = $row['rest_id'];
            $row_array['type_id'] = $row['type_id'];
            $row_array['rest_name'] = $row['rest_name'];
            $row_array['contacto'] = $row['contacto'];
            $row_array['id_hor'] = $row['id_hor'];
            $row_array['local'] = $row['local'];
            $row_array['descp'] = $row['descp'];
            $row_array['img'] = $row['img'];

            array_push($json_response,$row_array);

        }

    echo json_encode($json_response);
}// need to be close
fclose($conn);
$conn->close();

?>

You are missing } for if($cnt>0){