Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Parse Error

  1. #1
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parse Error

    I have a login script. then index page either displays login information, or forwards the user to the next page. i came home today, to find my script not functioning. it was working fine last night, and i don't remember changing anything.
    anyway, my errors are as follows:
    Parse error: parse error, unexpected $end in functions.php on line 53

    Fatal error: Call to undefined function: display_login() in list.php on line 5

    index.php contains
    PHP Code:
    <?php
    session_start
    ();
    require 
    'functions.php';
    if (isset(
    $_POST['username'])) {
        
    login($_POST['username'], $_POST['password']);
    } else {
        
    display_login();
    }
    ?>
    functions.php contains
    PHP Code:
    <?php
    function login($name$pass) {
        
    $lines file ('pass.txt');
        
    $fuser trim($lines[0]);
        
    $fpass trim($lines[1]);
        if ( (
    $_POST['username'] == $fuser) && ($_POST['password'] == $fpass) ) {
            
    $_SESSION['authed'] = true;
            
    header("Location: list.php");
            exit;
        } else {
            
    display_login("Please Try Again");
        }
    }
    function 
    display_login($msg "Please Login") {
    echo 
    '<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Holy Spirit Power</TITLE>
    </HEAD>
    <BODY><h1>' 
    $msg '</h1><FORM action="index.php" method="post" enctype="application/x-www-form-urlencoded">
            <TABLE>
                <TR>
                    <TD>    Username:
                    </TD>
                    <TD>                    
                        <INPUT TYPE="text" NAME="username">
                    </TD>
                </TR>
                <TR>
                    <TD>    Password:
                    </TD>
                    <TD>                    
                        <INPUT TYPE="Password" name="password">
                    </TD>
                </TR>
                <TR>
                    <TD>                    
                        <INPUT TYPE="Submit" value="Login">
                    </TD>
                    <TD>
                    </TD>
                </TR>
            </TABLE>
        </FORM></BODY></HTML>'
    ;
    ?>
    where are my errors coming from?
    Last edited by dswimboy; 04-06-2004 at 11:55 PM. Reason: forgot to enclose second PHP code block
    "There is more than one way to do it."

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The second error is caused by the first one.

    The first one i probably becaus the
    function display_login($msg = "Please Login") {

    doesn't have a closing bracket. I don't see one anyway. Your file should probably end like

    </FORM></BODY></HTML>';
    }
    ?>
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you for fixing my stupid little error.
    "There is more than one way to do it."

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're most welcome.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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