-1

I am getting this error: Parse error: syntax error, unexpected end of file, expecting '`'

Here is the code

<?php 

//create connection
$conn = new mysqli("localhost", "root", "","database");

//check connection
if($conn->connect_error)    
    die("Connection failed " . $conn->connect_error);

    $sql = "SELECT * FROM Book";
    $result = $conn->query($sql);

if ($result->num_rows > 0) 
  {
    echo "<table><tr> <th>ISBN</th> <th>Writer</th> <th>Title</th> <th>Pages</th><th>Year Published</th> <th>Publisher</th> </tr>";
    while($row = $result->fetch_assoc())    
    {
      echo "<tr><td>"  . $row[ISBN]. "</td><td>". $row[Writer] . "</td>" ;
      echo "<td> " . $row[Title] . "</td><td>" . $row[Number_of_pages] . "</td><td>" . $row[Year] . "</td><td>" . $row[Publishing_house] . "</td></tr>";
    }
    echo "</table>";

  } 
else 
{
    echo "0 results";
}

$conn->close();
?>

short_open_tag is on I even checked with an online php syntax checker and it says there are no syntax errors.

2 Answers2

0

You have an extra "`" in this line:

`   $result = $conn->query($sql);

just remove the backtick:

   $result = $conn->query($sql);
andrzejwp
  • 922
  • 4
  • 11
0

Remove the backtick (`) form this line :

`   $result = $conn->query($sql);

And as a side note, I would definitely suggest you write code in a nice code editor with proper syntax highlighting.

Anis R.
  • 6,656
  • 2
  • 15
  • 37