Jump to content

error check - driving me crazy


matthew798

Recommended Posts

Hey guys! The error is that it seems to display EVERYTHING regardless of the if and else statements. Also, it seems to stop evaluating the rest of the document that "includes" this as soon as its done with this one. dbconnect works and all the session vars carry properly... WTF is going on!?

<?php
session_start();
include 'dbconnect.php';

$username = $_SESSION['username'];

$q = mysql_query("SELECT User_type FROM account WHERE username = '$username'")
or die(mysql_error());

$permission = mysql_fetch_row($q);
$permission = $permission[0];

if(isset($_SESSION['username']) && $permission >= 2){

       echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>";
   echo $menu001;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu002;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu003;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu004;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu006;
   echo "</span></a></li>";}
   
   elseif($permission <= 1){ 
	   echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>";
	   echo $menu001;
	   echo "</span></a></li><li><a href=''><span>";
	   echo $menu002;
	   echo "</span></a></li><li><a href=''><span>";
	   echo $menu003;
	   echo "</span></a></li><li><a href=''><span>";
	   echo $menu004;
	   echo "</span></a></li>";}

else{
       echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>";
   echo $menu001;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu002;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu003;
   echo "</span></a></li><li><a href=''><span>";
   echo $menu005;
   echo "</span></a></li>";
   
   echo "<span>
   <form action='login.php' method='POST'>
   
	<input type='text' value='username' name='username'>
	<input type='text' value='password' name='password'>


	<input type='submit'>

	</form>

   </span>
   			</li>
          </ul>
        </div>
      </div>";}

  ?>

Link to comment
Share on other sites

isset() evaluates to on empty values such as '' or 0 or array(), could that be an issue?  Also note that the elseif, because it doesn't check $_SESSION['username'], can succeed even if $_SESSION['username'] is not set.  This would be clearer if it was not indented.

 

As for debugging why it stops execution, I would add some diagnostic print statements.  I often use a line like print "hello";, and I move the line around, checking whether that piece of code gets executed.  After a few tries I can narrow down the exact point that execution stops.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.