View Full Version : Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

01-06-2012, 10:33 PM
So, when I try to run this code in WAMP 2.2A P1 (32Bit) using PHP 5.3.8, I get the error

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\register.php on line 31

require('database.php'); //Include DB connection information

if (isset($_POST['register'])) { //Execute the following if form is submitted
$username = mysql_real_escape_string($_POST['username']); //Post username from form
$password = mysql_real_escape_string(sha1(md5($_POST['pass']))); //Post password from form and encrypt
$password_two = mysql_real_escape_string(sha1(md5($_POST['pass_two']))); //Post password from form and encrypt
if(empty($username) || empty($password) || empty($password_two)) { //Check for empty fields
die("<strong>Error:</strong> All fields are required in order to register an account.");

if(strlen($username) > 25) { //Check if username exceeds limit of 25 characters
die("<strong>Error:</strong> Your username may not exceed 25 characters.");

if (!preg_match("/[a-zA-Z0-9_-]/", $username)) { //Check for unallowed characters in username
die("<strong>Error:</strong> Your username may only contain letters (a-z), numbers (0-9), underscores (_) and hypens (-).");

if ($password != $password_two) { //Check if passwords match
die("<strong>Error:</strong> Your passwords do not match.");

$check = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$check2 = mysql_num_rows($check);
if ($check2 != 0) { //Check if account already exists witih this username
die("<strong>Error:</strong> There is already an existing account with the username <strong>$username</strong>.");

mysql_query("INSERT INTO `users` (`username`, `password`)VALUES ('$username', '$password')") OR die(mysql_error());
echo "Account created! You may now <a href="login.php">login</a>."; //LINE 31 HERE
}else{ //If form is not submitted display the form
<p style="font-size:21px;">Register</p>
<form method="post" action="">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="pass"><br>
Confirm Password: <input type="password" name="pass_two"><br>
<input type="submit" name="register" value="Register">

Thanks for the time! :)

01-06-2012, 10:37 PM
echo "Account created! You may now <a href=\"login.php\">login</a>.";

01-06-2012, 10:38 PM
Ah, thanks! /new to this