2

I want display the records by while cicle. The result must be inside the bootstrap html code. In this moment, when execute the page, display this error:

Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR) in ...

This is my php code:

include "connect.php";

if (!$query = $dbconn->query("
                SELECT 
                    *
                FROM
                    books
                ")) 
{
  echo "Error: " . $dbconn->error . ".";
  exit();
}else{
  if($query->num_rows > 0) {
    while($row = $query->fetch_array(MYSQLI_ASSOC))
    {
        "
        <li class=\"inline\">
        <span class=\"badge pull-right\">".$row['tot_books']."</span>";     
        "
        <a href=\"booksPage.php?k=".$row['books_sequence']\">"; echo $row['book_description']."<a/></li>";
    }
    // 
    $query->close();
  }
}
$dbconn->close();

How to fix it?

Frankie
  • 490
  • 8
  • 23
  • You are wrong concatenating strings and variables, specifically here: `$row['books_sequence']\">";` – Dez Apr 08 '17 at 11:38

1 Answers1

1

You have some wrong quote .. try using a correct sequnce of single and double quote

include "connect.php";

  if (!$query = $dbconn->query("
                  SELECT 
                      *
                  FROM
                      books
                  ")) {
    echo "Error: " . $dbconn->error . ".";
    exit();
  } else {
    if($query->num_rows > 0) {
      while($row = $query->fetch_array(MYSQLI_ASSOC))
      {
          "
          <li class='inline'>
          <span class='badge pull-right'>".$row['tot_books']."</span>";     
          "
          <a href='booksPage.php?k='".$row['books_sequence']."'>"; echo $row['book_description']."<a/></li>";
      }

      $query->close();
    }
  }
  $dbconn->close();
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107