누구든지이 일을 도와 줄 수 있습니다. 테이블에서 모든 데이터를 가져 오려고합니다. 하지만 그것은 부울로 반환 유지합니다. 부울이 주어진 이유는 무엇입니까
<?php
$con = mysqli_connect("localhost", "root", "", "student");
$query = "SELECT * FROM `announcement` ORDER BY `announce_id` DESC";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result)){
$data[] = $row;
}
echo json_encode($data);
?>
주어진 오류
했다 :> Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,
> boolean given in D:\Xampp\htdocs\student\announcement.php on line 8
>
> Notice: Undefined variable: data in
> D:\Xampp\htdocs\student\announcement.php on line 12 null
항상 ($ con, $ query) 또는 die ($ con-> error)' – Ghost
쿼리가 실패하면 부울 false를 반환했습니다. – nogad
[mysqli \ _fetch \ _array()/mysqli \ _fetch \ _assoc()/mysqli \ _fetch \ _row() 매개 변수 1 리소스 또는 mysqli \ _result, 부울 주어진] 기대 (http://stackoverflow.com/questions/2973202/mysqli-fetch-array-mysqli-fetch-assoc -mysqli-fetch-row-expects-parameter-1) –