Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/206166-simple-parse-error-question/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.