Results 1 to 6 of 6

Thread: Help!!

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Help!!

    What is the problem with this script?

    PHP Code:
    <?php 
    mysql_connect 
    (localhostuserpassword); 
    mysql_select_db (nz); 
    $qry mysql_query("SELECT user_name FROM DB_Wsers WHERE user_name='$user_name' LIMIT 1")

    if (
    $_POST['action'] == 'save') { 

    if(
    $_POST['user_password'] == $_POST ['user_password_confirm']){

    $result mysql_query ("INSERT INTO DB_Users Values ('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
    }else{
    echo 
    "Sorry";
    }

    $arr mysql_fetch_array($qry); 
    if(
    $arr[0] == ""){

    $result mysql_query ("INSERT INTO DB_Users Values ('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')"); 

    }else{ 
    echo 
    "That username is already in use.\n"
    }  
    } else { 
    ?> 

    Crap

    <?php
    }
    ?>

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    uh.. if you're posting scripts, don't just ask 'what is wrong with this?'.. give a description of what you want, what you're getting instead, including any parse errors.
    Like Archer? Check out some Sterling Archer quotes.

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    nevermind, you're missing a semi-colon on your mysql_query() call in this script too..

    add a semi-colon to the end of line 4 after the bracket.

    line 4 is this line:
    PHP Code:
    $qry mysql_query("SELECT user_name FROM DB_Wsers WHERE user_name='$user_name' LIMIT 1"
    change it to:
    PHP Code:
    $qry mysql_query("SELECT user_name FROM DB_Wsers WHERE user_name='$user_name' LIMIT 1"); 
    Like Archer? Check out some Sterling Archer quotes.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    Ok, if both are fine it add the record twice why?

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    uhh.. really, you should look into actually learning PHP a bit more..

    you've got two queries that insert information into the database at two different points.. you only want one instance where you are inserting data, not two.

    your script should be structured something like this, fill in the blanks:
    PHP Code:
    <?
      if($action == "save"){
        if($password1 == $password2){
          if($user[0] == ""){
            //insert user information to database
          }else{
            echo "user already exists";
          }
        }else{
          echo "passwords don't match";
        }
      }else{
        echo "action is not to save";
      }
    ?>
    Like Archer? Check out some Sterling Archer quotes.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    Originally posted by kows
    uhh.. really, you should look into actually learning PHP a bit more..

    you've got two queries that insert information into the database at two different points.. you only want one instance where you are inserting data, not two.

    your script should be structured something like this, fill in the blanks:
    PHP Code:
    <?
      if($action == "save"){
        if($password1 == $password2){
          if($user[0] == ""){
            //insert user information to database
          }else{
            echo "user already exists";
          }
        }else{
          echo "passwords don't match";
        }
      }else{
        echo "action is not to save";
      }
    ?>
    I don't use it enough to worry about learning a lot about it

Posting Permissions

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



Click Here to Expand Forum to Full Width