www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] IF.. ELSEIF.. ELSE.. problem

  1. #1
    Join Date
    Nov 2011
    Location
    Home, UK
    Posts
    15

    resolved [RESOLVED] IF.. ELSEIF.. ELSE.. problem

    Parse error: syntax error, unexpected T_ELSEIF in /login-exec.php on line 63

    the entire IF.. where it stop's it.
    i can't seem to find the glitch. but this is my first time dealing with ELSEIF

    about this IF .. there are only 3 possible outcomes what this IF has to check. yes, no or blank = ""
    for a ban feature

    its simple. if STATUS = YES, your banned
    if no. your not.
    if its empty. go to verify page (basic note, this account has not been verified.. bla bla bla) *hope it helps.
    note* i tryed with 1 =, and 2 ==, same error.
    i tried with qouates " and ' no difference

    thanks for your help
    PHP Code:
    if($result) {
            if(
    mysql_num_rows($result) == 1) {    
                
    //Login Successful
                
    session_regenerate_id();
                
    $member mysql_fetch_assoc($result);

                
    $_SESSION['SESS_USERNAME'] = $member['Username'];
                
    $_SESSION['SESS_PASSWORD'] = $member['Password'];
                
    $_SESSION['SESS_STATUS'] = $member['Status'];
                            
                if (
    $_SESSION['SESS_STATUS'] = "no")            
                    
    header("location: member-index.php");
                    
    session_write_close();
                    exit();
                elseif (
    $_SESSION['SESS_STATUS'] = "yes"// << the error says this ELSEIF
                    //banned
                    
    header("location: banned.php");
                    
    session_write_close();
                    exit();
                else (
    $_SESSION['SESS_STATUS'] = "")
                    
    //not authorised
                    
    header("location: verified.php");
                    
    session_write_close();
                    exit();
                }
        }
    ?> 
    Last edited by Sn00pY; 11-14-2011 at 10:12 AM.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,617
    You forgot the curly braces for each of those internal if/elseif/else blocks.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2011
    Location
    Home, UK
    Posts
    15
    fixed it, b4 i read. the below was my solution..

    *probly as NogDog suggested, he is a great help allways

    PHP Code:
    //Check whether the query was successful or not
        
    if($result) {
            if(
    mysql_num_rows($result) == 1) {    
                
    //Login Successful
                
    session_regenerate_id();
                
    $member mysql_fetch_assoc($result);

                
    $_SESSION['SESS_USERNAME'] = $member['Username'];
                
    $_SESSION['SESS_PASSWORD'] = $member['Password'];
                
    $_SESSION['SESS_STATUS'] = $member['Status'];
                            
                if (
    $_SESSION['SESS_STATUS'] == "no"){            
                    
    header("location: member-index.php");
                    
    session_write_close();
                    exit();
                        }
                else if (
    $_SESSION['SESS_STATUS'] == "yes"){
                    
    //banned  -line 65
                    
    header("location: banned.php");
                    
    session_write_close();
                    exit();
                    }
                else if (
    $_SESSION['SESS_STATUS'] == ""){
                    
    //not authorised
                    
    header("location: verified.php");
                    
    session_write_close();
                    exit();
                }
    else{

    }
    }
                    
    //login fail
                    
    header("location: login-fail.php");
                    
    session_write_close();
                    exit();
    }
    ?> 
    *editors note ; the code above works. tried n tested all state's myself.
    Last edited by Sn00pY; 11-14-2011 at 11:06 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles