Jump to content

unexpected error!!


LiamProductions

Recommended Posts

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\phpdesigner_tmp7.php on line 55

 

Thats the error i am getting heres the code:

 

registerdone.php:

<?php

if(!isset($_POST['submitReg'])) { 
if(!isset($_POST['username'])) {
	echo "Please enter a username";
}
else {
	if(!isset($_POST['pass'])) {
		echo "Please enter a password";
	}
	else {
		if(!isset($_POST['passConf'])) {
			echo "Please enter a confirm password";
			}
	else {
		if(!isset($_POST['email'])) {
			echo "Please enter a email address";
		}
	else {
		$user = $_POST['username'];
                        $user = strip_tags($user);
		$pass = $_POST['pass'];
		$passConf = $_POST['passConf'];
		$email = $_POST['email'];
                        $email = strip_tags($email);
		if(strlen($user) < 4 || strlen($user) > 15) {
			echo "You entered a too long or short username";
		}
		elseif(strlen($pass) < 6 || strlen($pass) > 50) {
			echo "You entered a too long or short username";
		}
		elseif(strlen($email) < 5 || strlen($pass) > 60) {
			echo "You entered a too long or short username";
		}
		else {
			if(!isset($_POST['sport'])) {
				echo "Please enter a favourite sport";
			}
                                elseif ($pass != $passConf) {
                            echo "Password did not match";
                                  }
			else {
				$sport = $_POST['sport'];

				if($sport != 'Football' && $sport != 'Basketball' && $sport != 'Tennis' && $sport != 'Hockey' && 
				$sport != 'Rugby' && $sport != 'Bike Riding' && $sport != 'Swimming') {
					echo "Please pick a favourite sport";
				}
                                    else {
                                          $IP = $_SERVER['REMOTE_ADDR'];
                                          $date = date('d/m/y');

                                       $connection = mysql_connect('localhost', 'liam_liam', 'code090');

                                      $storedata = mysql_query('INSERT INTO liam_database('Username, Password, Email, Favourite Sport, IP, date');  
                                      VALUES ( "'.addslashes($user).'"   
                                               "'.md5($pass).'"
                                               "'.addslashes($email).'"
                                               "'.addslashes($sport).'"
                                               "'.addslashes($IP).'"
                                               "'.addslashes($date).'" );
                                      or die(mysql_error());
                                      echo "Successfully Registered!";               

                                       mysql_close($connection);
			}
		}
		}
		}	
	}
	}
}
else {
echo "Please fill in the registration form!";
}
?>

 

Link to comment
Share on other sites

Its always helpful to highlight the line of the error. However, this particular error came from your query. It should be:

 

$storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date);  
                                      VALUES ( "'.addslashes($user).'"   
                                               "'.md5($pass).'"
                                               "'.addslashes($email).'"
                                               "'.addslashes($sport).'"
                                               "'.addslashes($IP).'"
                                               "'.addslashes($date).'" ') or die(mysql_error());

 

You had single quotes around your list of fields. You dont need them, and it causes an error because all of your query is surrounded with single quotes.

 

However, your still going to get an error. Your logic is flawed somewhere, since you have:

 

if(something){
}else{
}else{
}

 

Which doesn't make sense. It might simply be a case of a misplaced brace (}), i dont know.

Link to comment
Share on other sites

I've changed the code to this now:

 

<?php

if(!isset($_POST['submitReg'])) { 
if(!isset($_POST['username'])) {
	echo "Please enter a username";
}
else {
	if(!isset($_POST['pass'])) {
		echo "Please enter a password";
	}
	else {
		if(!isset($_POST['passConf'])) {
			echo "Please enter a confirm password";
			}
	else {
		if(!isset($_POST['email'])) {
			echo "Please enter a email address";
		}
	else {
		$user = $_POST['username'];
                        $user = strip_tags($user);
		$pass = $_POST['pass'];
		$passConf = $_POST['passConf'];
		$email = $_POST['email'];
                        $email = strip_tags($email);
		if(strlen($user) < 4 || strlen($user) > 15) {
			echo "You entered a too long or short username";
		}
		elseif(strlen($pass) < 6 || strlen($pass) > 50) {
			echo "You entered a too long or short username";
		}
		elseif(strlen($email) < 5 || strlen($pass) > 60) {
			echo "You entered a too long or short username";
		}
		else {
			if(!isset($_POST['sport'])) {
				echo "Please enter a favourite sport";
			}
                                elseif ($pass != $passConf) {
                            echo "Password did not match";
                                  }
			else {
				$sport = $_POST['sport'];

				if($sport != 'Football' && $sport != 'Basketball' && $sport != 'Tennis' && $sport != 'Hockey' && 
				$sport != 'Rugby' && $sport != 'Bike Riding' && $sport != 'Swimming') {
					echo "Please pick a favourite sport";
				}
                                    else {
                                          $IP = $_SERVER['REMOTE_ADDR'];
                                          $date = date('d/m/y');

                                       $connection = mysql_connect('localhost', 'liam_liam', 'code090');

                                      $storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date);  
                                      VALUES ( "'.addslashes($user).'"   
                                               "'.md5($pass).'"
                                               "'.addslashes($email).'"
                                               "'.addslashes($sport).'"
                                               "'.addslashes($IP).'"
                                               "'.addslashes($date).'" ') or die(mysql_error());
                                      echo "Successfully Registered!";               

                                       mysql_close($connection);
			}
		}
		}
		}	
	}
	}
}
}
else {
	echo "Please enter the fields!";
}
?>

 

Now, when i try to register it just keeps saying "Please enter a password" i can't seem to understand why when the field is set.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.