edah527 Posted January 30, 2008 Share Posted January 30, 2008 hi pplz, for my website, want people to register a name to have thier own account for forums, etc. when i wrote the script, tested it(apache 2.2). I got to the registration page, and when i finished filling it out(and did everything right ), it should go to a page that said "Registration was successful!" and the information would go into the MySQL table: "authusers". but instead it said: Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\registerfinished.php on line 9 this is what the files' info is: for the form file: <html> <head> <title>Register</title> </head> <body> <h1>Register</h1> <form action="http://localhost/registerfinished.php" method="post"> First Name:<br> <input type="text" name="first"><br> Last Name:<br> <input type="text" name="last"><br> Email:<br> <input type="text" name="email"><br> Desired username:<br> <input type="text" name="username"><br> Password:<br> <input type="password" name="password"><br> Verify Password:<br> <input type="password" name="password2"><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html> this is what the result page would be: <?php if (! isset($_POST["submit"])) { echo file_get_contents("C:\xampp\htdocs\register.html"); } else { $mysqli=mysqli_connect("localhost", "mysqluser1", "", "users"); if ($_POST["password"] != $_POST["password2"]) { echo "<p>The passwords don't match. Go back and try again.</p>"; } else { $query="INSERT INTO authusers ("first", "last", "email", "username", "password") VALUES (".$_POST["first"].", ".$_POST["last"].", ".$_POST["email"].", ".$_POST["username"].", ".$_POST["password"]."); $result=mysqli_query($query); if (! $result) { throw new Exception( "Registration problems were encountered!" ); } else { echo "<p>Registration was succussful!</p>"; } ?> please help me figure out the problem!!!! ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/ Share on other sites More sharing options...
trq Posted January 30, 2008 Share Posted January 30, 2008 Look at your query. Your using double quotes within double quotes. $query="INSERT INTO authusers (first, last, email, username, `password`) VALUES ('".$_POST["first"]."', '".$_POST["last"]."', '".$_POST["email"]."', '".$_POST["username"]."', '".$_POST["password"]."'); Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/#findComment-453044 Share on other sites More sharing options...
ThYGrEaTCoDeR201 Posted January 30, 2008 Share Posted January 30, 2008 Yea inside the mysql query that inserts, you cant have VALUES("HELLO") instead have VALUES('HELLO') Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/#findComment-453081 Share on other sites More sharing options...
cooldude832 Posted January 30, 2008 Share Posted January 30, 2008 you can have double quotes in your query for insertion (don't think its what you want), but couldn't lead the misleading continue <?php #i.e $q = "insert into `Table` (Field1,Field2) VALUES('\"I'm Quoted\"', 'I\'m not'"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/#findComment-453097 Share on other sites More sharing options...
edah527 Posted February 9, 2008 Author Share Posted February 9, 2008 k i fixed everything but now it says: "Parse error: syntax error, unexpected T_CATCH in C:\xampp\htdocs\registerfinished.php on line 18" wat do i do??? [move]???[/move] [move]???[/move] [move]???[/move] Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/#findComment-462373 Share on other sites More sharing options...
DyslexicDog Posted February 9, 2008 Share Posted February 9, 2008 Post the updated version of your code. Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/#findComment-462376 Share on other sites More sharing options...
edah527 Posted February 10, 2008 Author Share Posted February 10, 2008 Post the updated version of your code. k here it is: <?php if (! isset($_POST["submit"])) { echo file_get_contents("C:\xampp\htdocs\register.html"); } else { $mysqli=mysqli_connect("localhost", "mysqluser1", "", "users"); if ($_POST["password"] != $_POST["password2"]) { echo "<p>The passwords don't match. Go back and try again.</p>"; } else { $query="INSERT INTO authusers ('first', 'last', 'email', 'username', 'password') VALUES ('$_POST[first]', '$_POST[last]', '$_POST', '$_POST[username]', '$_POST[password]');"; $result=mysqli_query($mysqli, $query); if (! $result) { throw new Exception( "Registration problems were encountered!" ); } else { echo "<p>Registration was succussful!</p>"; } } catch(Exception $e) { echo "<p>".$e->getMessage(),"</p>"; } #endCatch } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88502-phpmysql-registration-form-i-need-help/#findComment-463523 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.