Immortal55 Posted August 8, 2006 Share Posted August 8, 2006 I keep getting this error for my script that I just finished making:Parse error: parse error, unexpected $ in /home/theblizz/public_html/studiocommunity/registration.php on line 81here is my script:[code=php:0]<?include('header.php');function checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters { return FALSE; }if( (!$name) or (!$uname) or (!$pass) or (!$pass_two) or (!$email) ) { echo('<center><h2>New User Registration</h2> <br> <form actoin="$php_self" method="post"> <table border="0"> <tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr> <tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr> '); } if( (checkEmail($email) == TRUE) && ($pass == $passTwo) ) { require_once('db_connect.php'); $conn = db_connect(); $db = mysql_select_db('theblizz_studio', $conn) or die ('Registration failure, try again.'); $sql = 'SELECT * FROM users'; $result = mysql_query($sql); $row = mysql_fetch_array($result); $usertaken = $row['uname']; if( $uname == $usertaken ) { echo('Username is already in use, please choose another<br> <a href="registration.php">Go Back</a>'); } else { $sql = 'INSERT INTO users (name, email, uname, pass) VALUES ("$name", "$email", "$uname", "$pass")'; $result = mysql_query($sql, $conn) or die ('Registration failure, try again.'); if ( $result ) { echo('Thanks, $name, you are now a member of the Studio Community!'); }}} else { if( $pass != $passTwo ) { echo('<font color="red">*Your passwords did not match.</font> <br><br> <center><h2>New User Registration</h2> <br> <form actoin="$php_self" method="post"> <table border="0"> <tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr> <tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>'); } else { echo('<font color="red">*Your E-mail address was not valid.</font> <br><br> <center><h2>New User Registration</h2> <br> <form actoin="$php_self" method="post"> <table border="0"> <tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr> <tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>'); }}?>[/code] Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 8, 2006 Share Posted August 8, 2006 for some reason the posts get all knocked out of whack when posting them. Anyways, that error means that you did not close an if/else/elseif statemnet somewhere. Look through your code and see if you can find it.Also a better way of using if/else/ifelse is like this.[code=php:0]if ($something == $something_else) { //do something}elseif ($something == $whatever) { //do something else}else{ //do whatever}[/code]Hope this helps,Tom Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 I dont know if its related or not... but [code=php:0]function checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters { return FALSE; }[/code]i think you mean [code=php:0]function checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters { return FALSE; }}[/code] Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted August 8, 2006 Author Share Posted August 8, 2006 Thank you, that worked! But now I cannot figure out why the email check is not working, im not getting an error anymore, but it is saying that my email is not valid right off the bat, and its showing 2 forms. Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Uhhh the function wont return true no matter what in its current state....try function checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters { return FALSE; }else { return TRUE;}} Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted August 8, 2006 Author Share Posted August 8, 2006 hmmm, no im still getting the same thing. here is the link so you can see:http://theblizz.org/studiocommunity/registration.php Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Something is wrong with your eregi thing i think... I just tested it my self a little... try[code=php:0]function checkEmail($email) { if(!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $email)) { return FALSE; } else { return TRUE; }}[/code] Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Oh and you realize your form is messed up right?$var = "bob";echo('hello "$var"');would out put hello "$var"I normally use echo "hello" . $var; Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted August 8, 2006 Author Share Posted August 8, 2006 Ah, thank you for the hint.But im still getting the email error. Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Just a sec... I'll rewrite your script... lol Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted August 8, 2006 Author Share Posted August 8, 2006 haha, well thank you! Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Hehe sorry I got a lil side tracked... Anyways here it is...[code=php:0]<?include('header.php');include('db_connect.php');$conn = db_connect();$db = mysql_select_db('dev', $conn) or die ('Database error. Please try again later.');function checkEmail($e) { if(!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $e)) { return FALSE; } else { return TRUE; }}$sub = $_POST['sub'];if($sub) { if($_POST['name']) { $name = $_POST['name']; } else { $error .= "Please enter a user name.<BR>"; } if($_POST['email']) { $email = $_POST['email']; if(checkEmail($email) != TRUE) { $error .= "Your Email Address is not valid.<BR>"; } } else { $error .= "Please enter an email address.<BR>"; } if($_POST['uname']) { $uname = $_POST['uname']; $q = "SELECT * from `users` WHERE `uname` = '" . $uname . "'"; @$num = mysql_num_rows($q); if($num > 0) { $error .= "Sorry the user name you requested is not available.<BR>"; } } else { $error .= "Please enter a username<BR>"; } if($_POST['pass']) { $pass = $_POST['pass']; } else { $error .= "Please enter a password<BR>"; } if($_POST['pass_two']) { $pass_two = $_POST['pass_two']; } else { if($pass) { $error .= "You did not enter your password a second time!<BR>"; } } if(($pass) && ($pass_two) && ($pass != $pass_two)) { $error .= "Your passwords do not match!<BR>"; }if(!$error) { $sql = "INSERT INTO `users` (`name`, `email`, `uname`, `pass`) VALUES ('" . $name . "', '" . $email . "', '" . $uname . "', '" . $pass . "')"; if(!mysql_query($sql, $conn)) { echo "Sorry! A database error has occured... Please try again later."; } else { $no_display = "yes"; ?> <meta http-equiv="refresh" content="0;url=<? echo $_SERVER['HTTP_SELF'] . "?success=yes&user=" . $uname; ?>"> <? }}}if($no_display != "yes"){?> <center><font color="red"><? if($error) { echo "<B>One or more errors occured:</b> <BR>" . $error; }?></font> <h2>New User Registration</h2> <br><?} if(($_GET['success'] != "yes") && ($no_display != "yes")) { ?> <form action="" method="post"> <table border="0"> <tr><td>Name:</td><td><input type="text" name="name" value="<?=$name;?>"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="<?=$email;?>"></td></tr> <tr><td>Username:</td><td><input type="text" name="uname" value="<?=$uname;?>"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass_two""></td></tr> <tr><td><input type="submit" name="sub" value="Submit"></td></tr> </form><? }else { echo "Thanks, " . $_GET['user'] . ", your are now a member of the Studio Community!"; }if($conn){mysql_close($conn);}?>[/code]If I were you I would limit the lengths of the names usernames emails and passwords... Also i would store the passwords in MD5... This script does work though :D(working copy up at the momment at http://corbin-dev.no-ip.org/reg/) Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted August 8, 2006 Author Share Posted August 8, 2006 Wow, thanks a lot!Although when I copy the code and paste it into DW its like triple spaced? :D Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Hmmm I dont know whats causin that lol Quote Link to comment 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.