I hav a syntax error in While

  <?php

    $query = "SELECT * FROM users";
    $sql = mysqli_query($link, "SELECT * FROM users img_file WHERE id='$id' ");

    $_SESSION['id'] = $id;
    $result=mysqli_query($link, "SELECT * FROM `textArea` WHERE id='$id'"); // запрос на выборку
    $result = mysqli_query($link, $query) or die(mysqli_error($link));

    function get_text($id) {
      $singles = mysqli_query($link, "SELECT * FROM users WHERE id='$id'");
      foreach ($singles as $single) {
        return $single;
      }
    }

    while($row=mysqli_fetch_assoc($result))
    {
      if(!empty($row['textArea']))
      echo  '<div class="media mb-4 p-4 status-content">' .

    // This while syntax error
      while ($row = mysqli_fetch_assoc ($sql)) {           
        if (!$row['img_file']) {
          echo '<img class="mr-5 avatar" src="https://themes.3rdwavemedia.com/instance/bs4/assets/images/profile.jpg"/>';
        } else {
          echo "<img class='mr-5 avatar' style='width:300px; border-radius: 100%;height: 300px;' src='" . $row['img_file'] . "' alt='' />";
        }              
      }

    '<div class="media-body">' .
    '<h4 class="text-author text-warning">' . $row['login'] . '</h4>' .

    '<p class="text-white">' . $row['textArea'] . '</p>' .

            '</div>'.
        '</div>';
    }
  ?>

Recommended Answers

All 3 Replies

While I think you meant line 23, usually you get more than "syntax error" so share that.

Next I checked for matching braces and that looked OK.
The ECHOs at 25 and 27 would be simplified to echo foo (simple) so to see if there's a syntax error inside the while.

Line 25 and 27 do need some fine tooth comb looking at as on 25 you echo ' and on line 27 you echo " so you need to really pick over those lines.

line 20 has a . instead of a ;

also line 31 needs to be echo '

commented: That line 20 error could be why 23 errors. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.