php - echo HTML not being outputted -


i have php code:

    <nav><ul>         <?php  if( (isset($_session['user_role']) ) && (false != $_session['user_role']) ) {     if( '2' == $_session['user_role'] )      {          echo "<li><a href='index.php'>home</a></li>";         echo "<li><a href='#'>about us</a></li>";         echo "<li><a href='#'>contact us</a></li>";         echo "<li><a href='loginpage.php'>login</a></li>";     }       elseif ('3' == $_session['user_role'] )      {          echo "<li><a href='index.php'>home</a></li>";         echo "<li><a href='#'>about us</a></li>";         echo "<li><a href='#'>contact us</a></li>";         echo "<li><a href='loginpage.php'>login</a></li>";         echo "<li><a href='#'>admin</a></li>";     }    }   ?>     <ul></nav> 

for reason html code being echoed out not displaying when run php file on browser.

any suggestions please?

this set session variable:

$con = mysqli_connect("localhost","root","","darrenvellaedp2") or die("error: " . mysqli_error($con));                  $result = "select userroleid tbl_users userroleid = 2" or die("error: " . mysqli_error($con));                  $res = $con->query($result);                  while($row = mysqli_fetch_array($res)) {                     $userroleid = $row['userroleid'];                      $_session['user_role'] = $userroleid;                 } 

if no output being generated, means first conditional if statement failing. i.e.:

if( (isset($_session['user_role']) ) && (false != $_session['user_role']) ) 

you should add var_dump($_session['user_role']) check session data there.

p.s. did remember add session_start(); @ beginning of script? i.e..

<?php  // start php session session_start();  ?> <nav><ul>      // rest of code 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -