LiamProductions Posted August 15, 2007 Share Posted August 15, 2007 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 https://forums.phpfreaks.com/topic/65014-unexpected-error/ Share on other sites More sharing options...
GingerRobot Posted August 15, 2007 Share Posted August 15, 2007 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 https://forums.phpfreaks.com/topic/65014-unexpected-error/#findComment-324462 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 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 https://forums.phpfreaks.com/topic/65014-unexpected-error/#findComment-324467 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 I fixed that there was a error in my form but now this is the error im getting: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Sport,IP,date); VALUES ( "liam" ' at line 1 Link to comment https://forums.phpfreaks.com/topic/65014-unexpected-error/#findComment-324469 Share on other sites More sharing options...
AndyB Posted August 15, 2007 Share Posted August 15, 2007 Stop double-posting. http://www.phpfreaks.com/forums/index.php/topic,154961.msg671333.html Thread locked. Link to comment https://forums.phpfreaks.com/topic/65014-unexpected-error/#findComment-324482 Share on other sites More sharing options...
Recommended Posts