Error, but only on 1 page

I have a required header to display a navigation menu on many pages on my site…
I notice I get an error when I go to 1 of them,

and works on the others

Here’s the PHP code in header.php

   if(!isset($_SESSION['id']))  {
    <ul class="navbar-nav">
      <li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
      <li class="nav-item"><a class="nav-link" href="register.php" role="button">Register</a></li>
     <?php } else {

          $sql =  "SELECT name, avatar FROM users WHERE id = :id AND display = 1";

          $STM = $conn->prepare($sql);
          $STM->bindParam(":id", $_SESSION['id']);
          $row1 = $STM->fetch();   

So why doesn’t the prepare() doesnt recognize $sql as an object on that page?

Oh, I didn’t include the connection string on the contact page…
My bad!!!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.