Em có đoạn code PHP dưới đây muốn đổ thành json sau khi chạy thì nó báo lỗi như này:
This page isn’t working
vuminhlam.000webhostapp.com is currently unable to handle this request.
HTTP ERROR 500
Ai đó cho em hỏi em sai ở đâu ạ. Em chỉ mới học lướt qua PHP rất mong mọi người chỉ giáo.
<?php
$connect = mysqli_connect("localhost", "Username", "Pass","NameDatabase");
mysqli_query($connect,"SET NAMES 'utf8'");
$query = "SELECT * FROM khoahoc";
$data = mysqli_query($connect, $query);
$arrayCource = array();
while ($row = mysqli_fetch_assoc($data)){
array_push($arrayCource, new Cource($row['id'],$row['tenkh'],$row['hocphi']));
}
echo json_encode($arrayCource)
class Cource{
function Cource($id, $ten, $hp){
$this-> ID = $id;
$this-> TenKH = $ten;
$this-> HocPhi = $hp;
}
}
?>