SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Parse error on registration?

    After some help from a user on this board I've finally managed to get to work on databases. At the moment I'm trying to create a login, registration etc area. I'm following a tutorial in a Professional PHP Programming, but slightly modified. I've changed the form inputs and it seems to be causing problems. When I fill out the forms on the registration page and press submit I get the following parse error:

    Parse error: parse error in /blah/blah/register.php on line 11

    Below is the code for register.php. I get the error where I have changed the form inputs. Any ideas what's wrong?

    PHP Code:
    <?php
    require 'functions.php';

    // Check if all the form entries are entered, if any form entry
    // is missing then send, error message page

    if ( (trim($form_name)=="") || (trim($form_password)=="") || 
           (
    trim($form_user_id)=="") || (trim($form_address)=="") || 
           (
    trim($form_password)=="") || (trim($form_password1)=="") || 
           (
    trim($form_icq)=="") || (trim($form_address)=="") ||
           (
    trim($form_homepage)=="")) ) {
       
    header("Location:[url]http://[/url]$HTTP_HOST/$DOCROOT/error2.htm"); 
       exit();

    } else if (
    $form_password != $form_password1) { 

       
    // If both the passwords are not the same then generate error message
       
    header("Location:[url]http://[/url]$HTTP_HOST/$DOCROOT/error3.htm");
       exit();
    }
    else {
    // Open a persistent connection with the Database
       
    if (!($link mysql_pconnect ($DB_SERVER$DB_LOGIN$DB_PASSWORD))) {
          
    DisplayErrMsg(sprintf("internal error %d:%s\n"
             
    mysql_errno(), mysql_error()));
          exit() ;
       }

     
    // Create the user record
       
    $balance 0.00;
       if (!(
    $newresult mysql_db_query($DB"INSERT INTO user_profile 
              (name,user_id,password,email,icq,address,
              homepage) VALUES 
              ('
    $form_name','$form_user_id','$form_password',
    '
    $form_email','$form_address_icq', '$form_address',
              '
    $form_homepage')"))) {
          
    DisplayErrMsg(sprintf("internal error %d:%s\n"
                                   
    mysql_errno(), mysql_error()));
          exit() ;
       }
       
    /* If Registration Successful, then display, else display error msg */
       
    header("Location:[url]http://[/url]$HTTP_HOST/$DOCROOT/registration_success.htm");
        
       exit();
    }

    ?>

  2. #2
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    line 11 should read:

    Code:
    header("Location:$HTTP_HOST/$DOCROOT/error2.htm");
    or similar...

    don't create HTML link when sending an HTTP header.

    (the actual parse error was nesting quotes without escaping them).

    S

  3. #3
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed what you mentioned but it didn't solve the problem

    Also that is line 12, not 11. Line 11 is this:

    (trim($form_homepage)=="")) ) {

    This is what a section of the original tutorial looked like:

    PHP Code:
    if ( (trim($form_name)=="") || (trim($form_password)=="") || 
           (
    trim($form_user_id)=="") || (trim($form_pin)=="") || 
           (
    trim($form_password)=="") || (trim($form_password1)=="") || 
           (
    trim($form_email_id)=="") || (trim($form_address_line1)=="") ||
           (
    trim($form_phone)=="") || (trim($form_city)==")" ||
           (
    trim($form_country)=="") || (trim($form_card_number)=="") ||
           (
    trim($form_card_expiry_date)=="")) ) {
       
    header("Location:[url]http://[/url]$HTTP_HOST/$DOCROOT/error2.htm"); 
       exit(); 
    This is what it looks like after I changed things to suit myself.

    PHP Code:
    if ( (trim($form_name)=="") || (trim($form_password)=="") || 
           (
    trim($form_user_id)=="") || (trim($form_address)=="") || 
           (
    trim($form_password)=="") || (trim($form_password1)=="") || 
           (
    trim($form_icq)=="") || (trim($form_address)=="") ||
           (
    trim($form_homepage)=="")) ) {
      
    header("Location:[url]http://[/url]$HTTP_HOST/$DOCROOT/error2.htm");  
       exit(); 
    It's only when I changed things it doesn't work. If I revert to the original code and add those tables in the database it works fine. It's rather annoying.

  4. #4
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sometimes it helps to break complex conditional statements into smaller chunks like this (see the extra parenthesis at the end of your condition block?

    S


    PHP Code:
    <?php
    if (
        (
         
    trim(
              
    $form_name
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_password
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_user_id
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_address
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_password
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_password1
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_icq
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_address
             
    )==""
        
    )
        ||
        (
         
    trim(
              
    $form_homepage
             
    )==""
        
    )
       )
      ) 
    // <---- here
    {

  5. #5
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanx a lot =) It's working now. I actually wondered about that extra bracket but I thought nothing of it because it was like that in the original code.

    Oh well, next time I'll be more careful =)

    Once again thanx


Bookmarks

Posting Permissions

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