Seaholme Posted June 29, 2010 Share Posted June 29, 2010 Hey guys, I'm literally just starting out (as of 2.5 hours ago!!) so I'm guessing this is really simple. I've read some stuff about PHP syntax and what makes things quit out on you, but still can't spot my error. I'm guessing it's probably because I don't know enough :S This isn't actually my coding (unfortunately!), it's one somebody else gave me as a login-style script to learn from, and I've been trying to learn via making modifications to it, so if some parts seem sensible and others totally crazy or whatever, that'd be me :X Anyway, the error reads: Parse error: syntax error, unexpected T_EXIT in /home/content/91/6351791/html/register.php on line 23 I've marked out line 23 for you guys with "***line23***" -- this isn't there in the actual code I'm using! Really appreciate any help and advice. If I've missed giving out any info., please let me know! <?php include('connect.php'); if($loggedin == '1') die("Sorry matey-o, you can't register another account while you're logged in!"); // Register Script // So, the register script is a sample of the basic elements of // coding used in a simple sim game, namely, putting new data // into databases. if(isset($_POST['submit'])) { // trim removes the whitespaces from the beginning and end of text // this keeps someone from having a username of " " $uname = trim($_POST['username']); // Make sure all forms were filled out. if((!isset($_POST['username'])) || (!isset($_POST['pass']) || (!isset($_POST['email'])) || ($uname == '') || ($_POST['pass'] == '') || ($email == '')) die("Please fill out the form completely. <br><br> ***line23*** <a href=register.php>Continue</a>"); // Make sure name hasn't already been used. $check = @mysql_query("SELECT id FROM players WHERE username = '$uname'"); $check = @mysql_num_rows($check); if($check > 0) die("Sorry, that username has already been taken. Please try again. <br><br> <a href=register.php>Continue</a>"); // Make sure email hasn't already been used more than twice. $check = @mysql_query("SELECT id FROM players WHERE email = '$email'"); $check = @mysql_num_rows($check); if($check >= 2) die("Sorry, you already seem to have the maximum number of accounts allowed per person. <br><br> <a href=register.php>Continue</a>"); // Encrypt password $pass = md5($_POST['pass']); $date = date("m/d/y"); // Finally, create the record. $newPlayer = @mysql_query("INSERT INTO players (username, password, registered, email) VALUES ('$uname', '$pass', '$date', '$email')") or die("Error: ".mysql_error()); echo 'You have been registered! You may now <a href=index.php>Log in</a>.'; } else { // A simple example of a form. echo '<form action=register.php method=post> Username: <input type=text name=username><br> Password: <input type=password name=pass><br> Email: <input type=text name=email><br> <input type=submit name=submit value=Submit> </form>'; } ?> Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/206166-simple-parse-error-question/ Share on other sites More sharing options...
Mchl Posted June 29, 2010 Share Posted June 29, 2010 unexpected T_EXIT usually means you have more unmatched { or } Edit: In your case you're missing one ) in this line. || (!isset($_POST['pass']) || You should probably learn to indent your code. Makes it ieasier to read. Quote Link to comment https://forums.phpfreaks.com/topic/206166-simple-parse-error-question/#findComment-1078657 Share on other sites More sharing options...
Seaholme Posted June 29, 2010 Author Share Posted June 29, 2010 Thanks a bunch for that! Fixed! I'll also give indenting a try. It's probably a good idea to start off with good habits! Quote Link to comment https://forums.phpfreaks.com/topic/206166-simple-parse-error-question/#findComment-1078660 Share on other sites More sharing options...
Mchl Posted June 29, 2010 Share Posted June 29, 2010 Could not agree more. Here's an example of how consistent coding stadard might look like: http://framework.zend.com/wiki/display/ZFDEV/ZF+Coding+Standards+%28RC%29 Note, it's not the 'one and only' standard. If you like something else better, use it. Just stick with it. Quote Link to comment https://forums.phpfreaks.com/topic/206166-simple-parse-error-question/#findComment-1078686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.