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 11 of 11

Thread: PHP problem

  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP problem

    Every time I try to use this code that I have used in the past it never works for me now. I always get error though out the whole thing. Can some one please help
    PHP Code:
    <?php 
     
    // Connects to your Database 

     
    mysql_connect("localhost""erero7_users""1gQ]J)4DQS!U") or die(mysql_error()); 

     
    mysql_select_db("erero7_account") or die(mysql_error()); 


     
    //This code runs if the form has been submitted

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



     
    //This makes sure they did not leave any fields blank

     
    if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2']) {
     
     * die(
    "You did not complete all of the required fields");

     *}



     
    // checks if the username is in use

     
    *if (!get_magic_quotes_gpc()) {

     * 
    $_POST['username'] = addslashes($_POST['username']);

     *}

     
    $usercheck $_POST['username'];

     
    $check mysql_query("SELECT username FROM users WHERE username = '$usercheck'"

    or die(
    mysql_error());

     
    $check2 mysql_num_rows($check);



     
    //if the name exists it gives an error

     
    if ($check2 != 0) {

     * die(
    'Sorry, the username '.$_POST['username'].' is already in use.');

     * * }


     
    // this makes sure both passwords entered match

     
    *if ($_POST['pass'] != $_POST['pass2']) {

     * die(
    'Your passwords did not match. ');

     *}



     *
    // here we encrypt the password and add slashes if needed

     
    *$_POST['pass'] = md5($_POST['pass']);

     *if (!
    get_magic_quotes_gpc()) {

     * 
    $_POST['pass'] = addslashes($_POST['pass']);

     * 
    $_POST['username'] = addslashes($_POST['username']);

     * *}



     
    // now we insert it into the database

     
    *$insert "INSERT INTO users (username, password)

     * *VALUES ('"
    .$_POST['username']."', '".$_POST['pass']."')";

     *
    $add_member mysql_query($insert);
     }

     
    ?>
     <p>YAY! Youre registered!</p>
    Last edited by erero7; 04-01-2013 at 12:49 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    You should probably tell us what error you're getting?

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh ya sorry the error I'm getting is.
    Parse error: syntax error, unexpected T_EXIT in /home/erero7/public_html/signup.php on line 20

  • #4
    Regular Coder
    Join Date
    Jun 2009
    Posts
    138
    Thanks
    3
    Thanked 19 Times in 19 Posts
    I am going to hazard a guess that is all those '*' you have from line 19 onwards...

  • #5
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thats weird that isn't there in my code, but they show up here

  • #6
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here this version shouldn't have any of the '*'
    PHP Code:
    <?php  
     
    // Connects to your Database  

     
    mysql_connect("localhost""erero7_users""1gQ]J)4DQS!U") or die(mysql_error());  

     
    mysql_select_db("erero7_account") or die(mysql_error());  


     
    //This code runs if the form has been submitted 

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



     
    //This makes sure they did not leave any fields blank 

     
    if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2']) { 
      
     die(
    "You did not complete all of the required fields"); 

     } 



     
    // checks if the username is in use 

     
    if (!get_magic_quotes_gpc()) { 

     
    $_POST['username'] = addslashes($_POST['username']); 

     } 

     
    $usercheck $_POST['username']; 

     
    $check mysql_query("SELECT username FROM users WHERE username = '$usercheck'")  

    or die(
    mysql_error()); 

     
    $check2 mysql_num_rows($check); 



     
    //if the name exists it gives an error 

     
    if ($check2 != 0) { 

     die(
    'Sorry, the username '.$_POST['username'].' is already in use.'); 

     } 


     
    // this makes sure both passwords entered match 

     
    if ($_POST['pass'] != $_POST['pass2']) { 

     die(
    'Your passwords did not match. '); 

     } 



     
    // here we encrypt the password and add slashes if needed 

     
    $_POST['pass'] = md5($_POST['pass']); 

     if (!
    get_magic_quotes_gpc()) { 

      
    $_POST['pass'] = addslashes($_POST['pass']); 

      
    $_POST['username'] = addslashes($_POST['username']); 





     
    // now we insert it into the database 

     
    $insert "INSERT INTO users (username, password) 

     VALUES ('"
    .$_POST['username']."', '".$_POST['pass']."')"

    $add_member mysql_query($insert); 
     } 

     
    ?> 
     <p>YAY! Youre registered!</p>

  • #7
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,292
    Thanks
    4
    Thanked 202 Times in 199 Posts
    There are no syntax errors in the correct version you posted.
    Dave .... HostMonster for all of your hosting needs

  • #8
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but I still get the syntax errors.

  • #9
    Regular Coder
    Join Date
    Jun 2009
    Posts
    138
    Thanks
    3
    Thanked 19 Times in 19 Posts
    Is that the script in its entirety?? Is there any other info above or below?? You are absolutely sure none of those '*' are in the original?? It seems convenient they started at row 19 and you had a parse error at line 20...

  • #10
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes im sure. I dont know why those ended up there.

  • #11
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry guys I went back and check out the code and after around the 50th time I found the problem. It is fixed now. Thanks for tying to help.


  •  

    Posting Permissions

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