V
V
vahan212020-02-20 19:07:31
PHP
vahan21, 2020-02-20 19:07:31

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\fotoclub\news.php on line 56?

Hello.

Tell me, please, what is the problem?

<?php 
              include("$_SERVER[DOCUMENT_ROOT]/config.php");
              if (isset($_GET['page'])) {
                $page = $_GET['page'];
              }
              else{
                $page = 1;
              }
              $count = 7;
              $count1 = ($page - 1) * $count;
              $sql = "
                SELECT * FROM `news_list` WHERE id < 0 LIMIT $count1, $count ORDER BY `id` DESC";
              $result = mysqli_query($db, $sql);
              $id = 1;
              while( $r = mysqli_fetch_assoc($result) ){ 
              ?>
              <div class="news-wid-list">
                <img src="img/news/<?php echo $r['img']; ?>" alt="">
                <div class="text-news-title">
                  <p class="textModal">
                    <span class="textModalSpan"><?php echo $r['news_title']; ?></span><br>
                  </p>
                  <a href="news-more-read.php?id=<?php echo $r["id"]; ?>">Շարունակելի</a>
                </div>
              </div>
              <?php } ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-02-20
@FanatPHP

The problem is the incorrect order of the operators in the query.
And the muscle cannot tell about it because the connection code is wrong. as correct: https://phpdelusions.net/mysqli/mysqli_connect

K
kalibr17, 2020-02-20
@kalibr17

Limit use after order by

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question