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 2 of 2

Thread: parse error

  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    141
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Exclamation parse error

    Parse error: syntax error, unexpected $end in /Applications/XAMPP/xamppfiles/htdocs/web/process.php on line 108

    I can't seem to find the error.. line 108 is the very last line of the code where the ?> is:
    Thanks in advanced.

    PHP Code:
    <?php
        
    //Start session
        
    session_start();
        
        
    //Include database connection details
        
    require_once('config.php');
        
        
    //Array to store validation errors
        
    $errmsg_arr = array();
        
        
    //Validation error flag
        
    $errflag false;
        
        
    //Connect to mysql server
        
    $link mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
        if(!
    $link) {
            die(
    'Failed to connect to server: ' mysql_error());
        }
        
        
    //Select database
        
    $db mysql_select_db(DB_DATABASE);
        if(!
    $db) {
            die(
    "Unable to select database");
        }
        
        
    //Function to sanitize values received from the form. Prevents SQL injection
        
    function clean($str) {
            
    $str = @trim($str);
            if(
    get_magic_quotes_gpc()) {
                
    $str stripslashes($str);
            }
            return 
    mysql_real_escape_string($str);
        }
        
        
    //Sanitize the POST values
        
    $fname clean($_POST['fname']);
        
    $lname clean($_POST['lname']);
        
    $login clean($_POST['login']);
        
    $password clean($_POST['password']);
        
    $cpassword clean($_POST['cpassword']);
        
    $email clean($_POST['email']);
        
        
    //Input Validations
        
    if($fname == '') {
            
    $errmsg_arr[] = 'First name missing';
            
    $errflag true;
        }
        if(
    $lname == '') {
            
    $errmsg_arr[] = 'Last name missing';
            
    $errflag true;
        }
        if(
    $login == '') {
            
    $errmsg_arr[] = 'Login ID missing';
            
    $errflag true;
        }
        if(
    $password == '') {
            
    $errmsg_arr[] = 'Password missing';
            
    $errflag true;
        }
        if(
    $cpassword == '') {
            
    $errmsg_arr[] = 'Confirm password missing';
            
    $errflag true;
            
            if(
    $email == '') {
            
    $errmsg_arr[] = 'Email Address is needed';
            
    $errflag true;
        }
        if( 
    strcmp($password$cpassword) != ) {
            
    $errmsg_arr[] = 'Passwords do not match';
            
    $errflag true;
        }
        
        
    //Check for duplicate login ID
        
    if($login != '') {
            
    $qry "SELECT * FROM members WHERE login='$login'";
            
    $result mysql_query($qry);
            if(
    $result) {
                if(
    mysql_num_rows($result) > 0) {
                    
    $errmsg_arr[] = 'Login ID already in use';
                    
    $errflag true;
                }
                @
    mysql_free_result($result);
            }
            else {
                die(
    "Query failed");
            }
        }
        
        
    //If there are input validations, redirect back to the registration form
        
    if($errflag) {
            
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
            
    session_write_close();
            
    header("location: register.php");
            exit();
        }

        
    //Create INSERT query
        
    $qry "INSERT INTO members(firstname, lastname, login, passwd, email) VALUES('$fname','$lname','$login','".md5($_POST['password'])."','$email')";
        
    $result = @mysql_query($qry);
        
        
    //Check whether the query was successful or not
        
    if($result) {
            
    header("location: success.php");
            exit();
        }else {
            die(
    "Query failed");
        }
    ?>

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    You missed a closing bracket here:
    Code:
     if($cpassword == '') { 
            $errmsg_arr[] = 'Confirm password missing'; 
            $errflag = true; 
             
            if($email == '') { 
            $errmsg_arr[] = 'Email Address is needed'; 
            $errflag = true; 
        } 
    }
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    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
    •