#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    17
    Rep Power
    0
    I accidentally messed up a page on my site, but I don't know how to fix it. It shows a php parse error now, and I think it's located between my astericks. I'm new at php and I've read the guides to change it, but I can't find out what's wrong. Can anybody help me?

    <html>
    <body bgcolor="FFE4C4" text="8B4513">
    <?php
    mysql_connect ('hostname', 'username', 'password');

    mysql_select_db (dbname);

    $result = mysql_query ("SELECT Username FROM Users
    WHERE Username = '$Username'
    ");
    if ($row = mysql_fetch_array($result)){
    print ("<b>The user name ");
    print ("$Username ");
    print ("is already taken.</b> Please go back to the registration page and enter a new user name. ");
    print ("<p>");
    $verify = "bad";}
    ***************************************
    else{

    $works = mysql_query ("INSERT into Users (Username, Password, Age, Country, EmailAddress) VALUES ('$Username', '$Password', '$Age', '$Country', '$EmailAddress')");
    **************************************
    print ($Username,);

    print ("<br> Thanks for registering.");
    }
    ?>
    </body>
    </html>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    print ($Username,);
    **************************************



    Your this line might have caused the parse error.

    try the following..


    <html>
    <body bgcolor="FFE4C4" text="8B4513">
    <?php
    $con=mysql_connect('localhost', 'username', 'password');
    //database connectivity.

    mysql_select_db('databasename',$con);
    //Select your database..

    $result = mysql_query ("SELECT Username FROM Users WHERE Username = '$Username'",$con);

    //Issue sql query..

    if(mysql_num_rows($result)>0){
    //record is already their in the database..

    echo "<b>The user name".$Username." is already taken.</b>n";
    echo "Please go back to the registration page and enter a new user name.";
    $verify = "bad";
    }else{
    //record is not their .so insert it now..

    $works = mysql_query ("INSERT into Users (Username, Password, Age, Country, EmailAddress) VALUES ('$Username', '$Password', '$Age', '$Country', '$EmailAddress')",$con);

    //issue insert sql statement...

    if($works){
    //Record added to the database..
    echo $Username;
    echo "<br> Thanks for registering.";
    }else{
    //couldn't insert the record due to parse error.

    echo "Error while inserting that recordn";
    exit;
    }
    }
    ?>

    </body>
    </html>


    Make sure that you are creating users table with 5 fields(ie,Username, Password, Age, Country, EmailAddress).


    Good Luck!!!


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."


    [This message has been edited by Shiju Rajan (edited August 01, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    17
    Rep Power
    0
    You are awesome!
    Thank you very much, it worked; and you made the new script easy to understand so I can use some parts of it again.

Similar Threads

  1. simple form, simple trigger, whats wrong ??
    By zishto in forum Oracle Development
    Replies: 3
    Last Post: January 12th, 2004, 01:25 PM
  2. what is wrong with this code ????
    By fule in forum Database Management
    Replies: 1
    Last Post: November 20th, 2003, 01:24 AM
  3. *sigh*
    By vb.net in forum Dev Shed Lounge
    Replies: 45
    Last Post: November 9th, 2003, 07:52 PM
  4. offsetHeight returning the wrong height
    By Tobbe in forum HTML Programming
    Replies: 10
    Last Post: October 19th, 2003, 08:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo