I am trying to learn PHP and naturally some difficulties arise. Here is the code itself:

<?php require_once('dbconfig.php'); \\ подключение базы $result = mysqli_query($connect, "SELECT * FROM `article`"); if ($result = false) echo "Ошибка соединения"; while ($row = mysqli_fetch_assoc($result)){ echo $row['id_article'] . '<br>'; echo $row['title'] . '<br>'; echo $row['content'] . '<br>'; } ?> 

When implementing this code, it gives an error

Warning: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, boolean given in C: \ xampp \ htdocs \ sources \ insert.php on line 7

What is the problem? Tell me.

Reported as a duplicate by participants Alexey Shimansky , Pavel Mayorov , Lex Hobbit , br3t , Cheg 5 Sep '17 at 23:23 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • why, well, why no one uses the search here and immediately presses on the "Ask a Question"? - Alexey Shimansky
  • @ Alexey Shimansky, not a duplicate. By assigning it, it overwrites the result of the call, so there is no reason to assume that mysqli_query ended with an error. - Qwertiy
  • @Qwertiy well means "caused by a typo", but at the same time it does not change the fact that you need to search at the beginning on the resource and not immediately press buttons - Alexey Shimansky
  • @ Alexey Shimansky, you need to find a duplicate on = instead of == - surely there is one. - Qwertiy

1 answer 1

Instead of if ($result = false) write if ($result === false) . http://php.net/manual/ru/language.operators.comparison.php