SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    0 Post(s)
    0 Thread(s)

    Random error in code

    ive just written the code to register new users on my site but i get an error when i try to run it:

    Parse error: parse error, unexpected $end in e:\wamp\www\school of systems engineering\registrationform.php on line 131

    this is totally beyond me, or maybe ive just been starin at it toolong. but i really cant find the error. here's d code, i appreciate any help. please sum1 look at it and see if u can find anything. cheers.

    by the way line 131 is the line with th closing html tag.

    <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <title>User Registration Form</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    // Connect to the database server
    $dbcnx = @mysql_connect('localhost', 'root', '');
    if (!$dbcnx) {
    exit('<p>Unable to connect to the ' .
    'database server at this time.</p>');

    // Select the events database
    if (!@mysql_select_db('ssenet')) {
    exit('<p>Unable to locate the ' .
    'database at this time.</p>');


    <?php if (!isset($_POST['register'])) {

    <form name="form1" id="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
    <pre>First name: <input type="text" name="firstname" /></pre>
    <pre>Last name: <input type="text" name="lastname" /></pre>
    <pre>Email address: <input type="text" name="email" /></pre>
    <pre>User name: <input type="text" name="username" /></pre>
    <pre>User type: <select name="usertype"><option value="1" selected="selected">Academic</option><option value="2">Administrative</option><option value="3">Technical</option><option value="4">Administrator</option></select>

    <input type="submit" name="register" value="Submit" />


    else {

    if ($_POST['firstname']=='' or $_POST['lastname']==''
    or $_POST['email']=='' or $_POST['username']==' ') {
    error('One or more required fields were left blank.\\n'.
    'Please fill them in and try again.'); }

    else {

    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $email = $_POST['email'];
    $username = $_POST['username'];
    $usertype = $_POST['usertype'];

    $firstname = stripslashes($firstname);
    $lastname = stripslashes($lastname);
    $email = stripslashes($email);
    $username = stripslashes($username);
    $usertype = stripslashes($usertype);

    $checkdbemail = mysql_query("SELECT email_address FROM users WHERE email_address='$email'");
    $checkdbuser = mysql_query("SELECT username FROM users WHERE username='$username'");

    $email_check = mysql_num_rows($checkdbemail);
    $username_check = mysql_num_rows($checkdbuser);

    if(($email_check > 0) || ($username_check > 0))
    echo "Please fix the following errors: <br />";
    if($email_check > 0){
    error('That email address belongs to another user.\\n'.
    'Please try another.'); }
    if($username_check > 0){
    error('The username already exists.\\n'.
    'Please try another.'); }

    $newpass = substr(md5(time()),0,6);

    $sql = mysql_query("INSERT INTO users (first_name, last_name, email_address,
    username, password, user_level, signup_date)
    VALUES('$firstname', '$lastname', '$email',
    '$username', '$db_password', $usertype, now())");

    error('A database error occurred in processing your '.
    'submission.\\nIf this error persists, please '.
    else {

    echo $usertype;
    $userid = mysql_insert_id();
    // Let's mail the user!
    $subject = "Your Membership at MyWebsite!";
    $message = "Dear $firstname $lastname,
    Thank you for registering at our website, http://localhost/School%20of%20Systems%20Engineering/

    Your personal account for the School of Systems Engineering Intranet has been created! To log in, proceed to the
    following address:

    Your personal login ID and password are as follows:

    Username: $username
    Password: $newpass

    The Webmaster

    This is an automated response, please do not reply!";

    mail($email, $subject, $message,
    X-Mailer: PHP/" . phpversion());
    echo 'Membership information has been mailed to the user!';


    echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?register=1">Register a new user</a></p>';

  2. #2
    Join Date
    Jan 2003
    0 Post(s)
    0 Thread(s)
    You've just gone and posted your problem in the wrong forum friend...

    We have enough problems of our own around here, without any more, thank you very much

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    West Springfield, Massachusetts
    198 Post(s)
    3 Thread(s)


    I don't know why you would say the error is "random", actually once you know what it means, it says a lot. Count the number of starting braces "{" and the number of ending braces "}" and make sure they pair up.
    Off Topic:

    some of us have more problems than others

  4. #4
    SitePoint Member
    Join Date
    Jan 2006
    0 Post(s)
    0 Thread(s)
    thanks a lot , sorry to bother everyone, ive been staring at the screen for the past 19hrs. dunno why that didnt occur to me. its all sorted now. cheers.


Posting Permissions

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