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

Thread: $end error

  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts

    Angry $end error

    Im making a register form and all seems to be fine apart from 1 error:
    Parse error: syntax error, unexpected $end in /web/sites/vhbu/0/156/51648/public/www2/test/register.php on line 71

    heres my code:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <?php
    require_once ('./mysql/config.inc.php');
    $page_title 'Register';
    if (isset(
    $_POST['submitted'])) {
    require_once (
    '../mysql/mysql_connect.php');
    if (
    eregi ('^[[:alpha :]\.\' \-] {2,15}$',stripslashes(trim($_POST['first_name'])))) {
    $fn escape_data($_POST['first_name']);
    } else {
    $fn FALSE;
    echo 
    '<p><font color="red" size="+1">Please enter your first name!</font></p>';
    }
    if (
    eregi ('^[[:alpha:]\.\' \-] {2,30}$' stripslashes(trim($_POST['last_name'])))) {
    $ln escape_data($_POST['last_name']);
    } else {
    $ln FALSE;
    echo 
    '<p><font color="red" size="+1">Please enter your last name!</font></p>';
    }
    if (
    eregi ('^[[:alnum:]] {4,20}$' stripslashes(trim($_POST['password1'])))) {
    if (
    $_POST['password'] == $_POST['password2']) {
    $p escape_data($_POST['password1']);
    } else {
    $p FALSE;
    echo 
    '<p><font color="red" size="+1">Please enter a valid password!</font></p>';
    }
    if (
    $fn && $ln && $e && $p) {
    $query "SELECT user_id FROM users WHERE email='$e'";
    $result mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " mysql_error());
    if (
    mysql_num_rows($result) == 0) {
    $a md5(uniqid(rand(), true));
    $query "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln', '$a', NOW()";
    $result mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " mysql_error());
    if (
    mysql_affected_rows() == 1) {
    $body "Thank you for regestering for Planet 1990's. To activate your account, please click on this link:";
    $body .= "http://www2.hanwellvillage.com/activate.php?x=" mysql_insert_id() . "&y=$a";
    mail($_POST['email'], 'Registration Confirmation' $body);
    echo 
    '<h3>Thank you for registering! A Confomation email has been sent to you address. Please click on the link in that email in order to activate your account.</h3>';
    exit();
    } else{
    echo 
    '<p><font color="red" size="+1">You could not register due to a system error. We apoligize for any inconvenience.</font></p>';
    }
    } else {
    echo 
    '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to habe your password sent to you.</font></p>';
    }
    } else {
    echo 
    '<p><font color="red" size="+1">Please try again</font></p>';
    }
    mysql_close();
    }
    ?>
    <h1>Register</h1>
    <form action="register.php" method="post">
    <fieldset>
    <p><b>First Name:</b> <input type="text" name="first_name" size="30" maxlength="30" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>
    <p><b>Last Name:</b> <input type="text" name="last_name" size="30" maxlength="30" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>
    <p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email'?>" /></p>
    <p><b>Password:</b> <input type="password" name="password1" size="25" maxlength="20" /><small>Use only letters and numbers. Must be between 4 and 20 charaters long.</small></p>
    <p><b>Confirm Password:</b> <input type="password" name="password2" size="25" maxlength="20" /></p>
    </fieldset>
    <div align="center"><input type="submit" value="Register!" /></div>
    <input type="hidden" name="submitted" value="TRUE" />
    </form>
    </body>
    </html>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I think it helps when you format your code like this
    PHP Code:
    <?php
    require_once ('./mysql/config.inc.php');
    $page_title 'Register';
    if (isset(
    $_POST['submitted']))
    {
        require_once (
    '../mysql/mysql_connect.php');
        if (
    eregi ('^[[:alpha :]\.\' \-] {2,15}$',stripslashes(trim($_POST['first_name']))))
        {
            
    $fn escape_data($_POST['first_name']);
        }
        else 
        {
            
    $fn FALSE;
            echo 
    '<p><font color="red" size="+1">Please enter your first name!</font></p>';
        }
        if (
    eregi ('^[[:alpha:]\.\' \-] {2,30}$' stripslashes(trim($_POST['last_name']))))
        {
            
    $ln escape_data($_POST['last_name']);
        }
        else
        {
            
    $ln FALSE;
            echo 
    '<p><font color="red" size="+1">Please enter your last name!</font></p>';
        }
        if (
    eregi ('^[[:alnum:]] {4,20}$' stripslashes(trim($_POST['password1']))))
        {
            if (
    $_POST['password'] == $_POST['password2'])
            {
                
    $p escape_data($_POST['password1']);
            }
            else
            {
                
    $p FALSE;
                echo 
    '<p><font color="red" size="+1">Please enter a valid password!</font></p>';
            }
            if (
    $fn && $ln && $e && $p)
            {
                
    $query "SELECT user_id FROM users WHERE email='$e'";
                
    $result mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " mysql_error());
                if (
    mysql_num_rows($result) == 0)
                {
                    
    $a md5(uniqid(rand(), true));
                    
    $query "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln', '$a', NOW()";
                    
    $result mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " mysql_error());
                    if (
    mysql_affected_rows() == 1)
                    {
                        
    $body "Thank you for regestering for Planet 1990's. To activate your account, please click on this link:";
                        
    $body .= "http://www2.hanwellvillage.com/activate.php?x=" mysql_insert_id() . "&y=$a";
                        
    mail($_POST['email'], 'Registration Confirmation' $body);
                        echo 
    '<h3>Thank you for registering! A Confomation email has been sent to you address. Please click on the link in that email in order to activate your account.</h3>';
                        exit();
                    }
                    else
                    {
                        echo 
    '<p><font color="red" size="+1">You could not register due to a system error. We apoligize for any inconvenience.</font></p>';
                    }
                }
                else
                {
                    echo 
    '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to habe your password sent to you.</font></p>';
                }
            }
            else
            {
                echo 
    '<p><font color="red" size="+1">Please try again</font></p>';
            }
        
    mysql_close();
    }
    ?>
    From this you see you never close this if statement
    PHP Code:
        if (eregi ('^[[:alnum:]] {4,20}$' stripslashes(trim($_POST['password1'])))) 
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts
    how do i close it though? nvm i think ive seen

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts
    fixed now im getting:
    Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /web/sites/vhbu/0/156/51648/public/www2/test/mysql/config.inc.php on line 6

    on line six is
    PHP Code:
    </head
    ooops sorry thts wrong didnt read error right

    but here is my config.inc.php file
    PHP Code:
    <?php
    $live 
    FALSE;
    $email 'my email address';
    function 
    my_error_handler ($e_number$e_message$e_file$e_line$e_vars){
    global 
    $live$email
    $message 
    "An Error occurred in script '$e_file on line $e_line: \n<br /> $e_message\n<br />";
    $message .= "Date/Time: " date('n-j-Y H:i:s') . "\n<br />";
    $message .= "<pre>" print_r ($e_vars1) . "</pre>\n<br />";
    if (
    $live) {
    error_log ($message1$email);
    if (
    $e_number != E_NOTICE) {
    echo 
    '<div id="Error">A system error occurred. We apologize for the inconveince.</div><br />';
    }
    } else {
    echo 
    '<div id="Error">' $message '</div><br />';
    }
    }
    set_error_handler ('my_error_handler');
    ?>
    i dunno wat the error is?? Sorry im being such a noob =P
    Last edited by tyanque; 06-07-2007 at 10:29 PM.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Missing a ; on this line
    PHP Code:
    global $live$email 
    I suggest you start paying attention to what you type. These are simple errors.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts
    is escape_data() a valid function if not what is the replacement?

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I'm guessing you are concerned about the info going into the database. If this is the case then use mysql_real_escape_string('somestring')
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts
    yup thts wat i was looking for thanks


  •  

    Posting Permissions

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