papillonstudios Posted August 31, 2009 Share Posted August 31, 2009 I have just recoded my registration form for my cms to make it look more appealing. But im having a slight problem i get this error Parse error: parse error, unexpected $ in register.php on line 166 and i cant seem to find whats wrong with it. I knows its something small that im just missing. <?php /* iSuS - iScripting.net User System v2 made by GamingFusion http://gamingfusion.net Copyright must stay intact */ //If they're already logged in, they don't need to register an account. Redirect them if ($logged['id']) { header("Location: " . $siteurl . "/index.php"); } else { // Or else they are a guest, they can register.. //If the form hasn't been submitted, show it! if (!$_POST['submit']) { echo '<div> <form action="index.php?action=register" method="POST"> <fieldset> <legend> User Information </legend> <p>Username '.form_input(text,username).'</p> <p>Password '.form_input(password,password).' '.form_input(password,cpassword).'</p> <p>Email '.form_input(text,email).'</p> </fieldset> </p> <p> <fieldset> <legend> Secret Question </legend> <p> <select name="question"> <option value="Select One">Select One</option> <option value="What was the name of your first pet?">What was the name of your first pet?</option> <option value="What is your mother maiden name?">What is your mother maiden name?</option> <option value="What was your first car?">What was your first car?</option> <option value="What is your favorite band?">What is your favorite band?</option> <option value="What was the name of your favorite teacher?">What was the name of your favorite teacher?</option> </select> </p> Answer <input type="text" size="25"> </fieldset> </p> <p> <fieldset> <legend> Gender </legend> <p><input type="radio" name="gender" value="male" /> Male</p> <p><input type="radio" name="gender" value="female" /> Female</p> </fieldset> </p> <p>'.form_checkbox(terms).''.anchor('index.php?action=viewterms', 'I agree to TOS').'</p> <p>'.form_button(submit,submit,Register).'</p> </form> </div> '; } else { //Or else it has.. Secure all the inputs $username = secure($_POST['username']); $password = secure($_POST['password']); $cpassword = secure($_POST['cpassword']); $email = secure($_POST['email']); $gender = secure($_POST['gender']); $question = secure($_POST['question']); $answer = secure($_POST['answer']); $terms = secure($_POST['terms']); //Get their IP Address $ip = secure($_SERVER['REMOTE_ADDR']); //And the time they signed up $signup = date("d-m-Y"); //And Set their Avatar if ($gender == 'male') { $avatar = $siteurl. 'i/avatar_m.png'; }else{ $avatar = $siteurl. 'i/avatar_f.png'; } //If anything is empty... if (!$username | !$wow | !$password | !$cpassword | !$email | !$terms) { echo '<img src="i/warning.png" alt="warning">Please Fill out all fields on the form.'; } else { //if the question and answer are empty... if (!$question | !$answer) { echo 'PLease Fill out the Secret Question and answer fields.'; }else{ //If the passwords dont match if ($password != $cpassword) { echo 'The passwords do not match'; } else { //If the email they entered wasn't an authentic email.. if (!isEmail($email)) { echo "Email address invalid"; } else { //Is the username that they are trying to use already in use? $username_test = mysql_query("SELECT * FROM `users` WHERE username = '$username'"); if (mysql_num_rows($username_test) == 1) { echo 'That username is already in use, please select a different one'; } else { //Encrypt the password $encpass = sha1($password . SALT); //Insert the user information into the database $add = "INSERT INTO `users` VALUES ('', '$username', '$encpass', '$email', '', '','','', '$ip', '$signup', 'user','', '$gender', '$avatar', '$question', '$answer')"; //If the insert went ok... if (mysql_query($add)) { //Tell them their user info echo 'Success, you are now registered<br />'; echo 'You can now login using the following information<br /><br />'; echo "Username: <strong>$username</strong><br />"; echo "Password: <strong>$password</strong><br />"; echo "Login <a href='index.php?action=login'>Go</a>"; } else { echo 'Error, Registration not complete. Please contact your administrator. <br />'.mysql_error(); } } } } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/172538-solved-unexpected-error/ Share on other sites More sharing options...
oni-kun Posted August 31, 2009 Share Posted August 31, 2009 There is no line 166, but from the error it's shown you've added the $ character unescaped somewhere in a string. Note you cannot use.. "$3 is the price" You have to use: "\$3 is your price." That is why it says unexpected '$' Quote Link to comment https://forums.phpfreaks.com/topic/172538-solved-unexpected-error/#findComment-909526 Share on other sites More sharing options...
Philip Posted August 31, 2009 Share Posted August 31, 2009 You're missing a closing bracket for your if ($logged['id']) { header("Location: " . $siteurl . "/index.php"); } else { //... // missing } ?> Quote Link to comment https://forums.phpfreaks.com/topic/172538-solved-unexpected-error/#findComment-909527 Share on other sites More sharing options...
papillonstudios Posted August 31, 2009 Author Share Posted August 31, 2009 You're missing a closing bracket for your if ($logged['id']) { header("Location: " . $siteurl . "/index.php"); } else { //... // missing } ?> Thanks man i knew it was something small like that. Quote Link to comment https://forums.phpfreaks.com/topic/172538-solved-unexpected-error/#findComment-909529 Share on other sites More sharing options...
Daniel0 Posted August 31, 2009 Share Posted August 31, 2009 There is no line 166, but from the error it's shown you've added the $ character unescaped somewhere in a string. Note you cannot use.. "$3 is the price" You have to use: "\$3 is your price." That is why it says unexpected '$' Yes, you can. If something contains a $-sign, but cannot be interpreted as a variable, PHP will just ignore it and not try to substitute it. Quote Link to comment https://forums.phpfreaks.com/topic/172538-solved-unexpected-error/#findComment-909531 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.