Как исправить warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result?
Не понимаю в чём ошибка:
"Fatal error: Uncaught TypeError: mysqli_fetch_assoc(): Argument #1 ($result) must be of type mysqli_result, bool given in D:\XSAMP\htdocs\Kinomonster\index.php:15 Stack trace: #0 D:\XSAMP\htdocs\Kinomonster\index.php(15): mysqli_fetch_assoc(false) #1 {main} thrown in D:\XSAMP\htdocs\Kinomonster\index.php on line 15"?
Вот код:
<?php
$mysqli = new mysqli('localhost', 'root', '', 'kinomonster');
if(mysqli_connect_errno()) {
printf("Соединение не установлено", mysqli_connect_error());
exit();
}
$mysqli->set_charset('utf8mb4_general_ci');
$query = $mysqli->query("SELECT * FROM movie");
while ($row =mysqli_fetch_assoc($query) ) {
echo $row['name'];
}
$mysqli->close();
?>