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
  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Its me again! Another PHP question :P

    Well, I've looked and looked and check and doubled check. And me being a noob at PHP, I just don't know what else to really look for. I keep on getting a error being:'Parse error: syntax error, unexpected $end in'. So heres my script:

    PHP Code:

    <?php

    $_SERVER
    ['REMOTE_ADDR'];

    //Find out if the user name is being used or not

    if(isset($_POST['submit']))

    {

      include(
    "db.php");
      
      
    $query mysql_query("SELECT fname FROM register WHERE fname='{$_POST['fname']}'") or die('Database error: '.mysql_error());
      
      
    $num_rows mysql_num_rows($query);
      
      if(
    $num_rows >0)
      
      {
      
      
    $usertaken 'Sorry, this user name is already being used';
        
      }
      else
      
      {
      
      echo 
    '';
      
      } 
      
     
    // Find out if the input fields are filled in and find out if the password matchs. 
        
        
        
    include("db.php"); // connect to database

         
    if(isset($_POST['submit']))

    {

    if(empty(
    $_POST['Username']))
        {
        
    $msg1 'Please fill in your User name';
        }
    else if(empty(
    $_POST['Password']))
        {
        
    $msg2 'Please fill in your password, and then retype it.';
        }
    else if(
    $_POST['Password'] != $_POST['Comfirmed_password'])
       {
       
    $passMatch 'Your Passwords do not match. Please retype them again';
       }
    else if(empty(
    $_POST['Firstname']))
       {
       
    $msg3 'Please fill in your first name';
       } 
    else if(empty(
    $_POST['Lastname']))
       {
       
    $msg4 'Please fill in your Last Name';
       }
    }   
       
        else {
          
          
    //Everything checked out ok, so insert into the database time.
          
            
    $query mysql_query("INSERT INTO register(`IP`, `Username`, `Password`, `Email`, `Firstname`, `Lastname`) VALUES('".$_POST['IP']."', '".mysql_real_escape_string($_POST['Username'])."', '".mysql_real_escape_string(md5($_POST['Password']))."', '".mysql_real_escape_string($_POST['Email'])."', '".mysql_real_escape_string($_POST['Firstname'])."', '".mysql_real_escape_string($_POST['Lastname'])."')") or die('Database error: '.mysql_error());
            
            
            }     

    ?>

    Thanks a ton for helping me out guys. You guys have been wonderful.

    Thanks again
    Jon W

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    You're missing a closing brace to your initial if switch. But more importantly you have an if/else inside of another with the same condition, which makes no sense. And you're including db.php twice for no apparent reason.


  •  

    Posting Permissions

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