edah527 Posted February 23, 2008 Share Posted February 23, 2008 Ive got a problem every time i try to fix this; here is the errer message: Parse error: syntax error, unexpected T_CATCH in C:\xampp\htdocs\register2.php on line 18 and here is the code for the finished part of registration: <?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($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 Share on other sites More sharing options...
Coreye Posted February 23, 2008 Share Posted February 23, 2008 You should ask this on the PHP help board here: http://www.phpfreaks.com/forums/index.php/board,1.0.html. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 24, 2008 Share Posted February 24, 2008 Trie this way ok....... <?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($mysqli, $query); if (! $result) { throw new Exception("Registration problems were encountered!"); } else { echo "<p>Registration was succussful!</p>"; } } $e="This wasent here before"; //defineing varable $e throw new Exception($e); echo $e->getMessage(); } ?> Quote Link to comment Share on other sites More sharing options...
edah527 Posted February 29, 2008 Author Share Posted February 29, 2008 tried; dint help: Fatal error: Uncaught exception 'Exception' with message 'Registration problems were encountered!' in C:\xampp\htdocs\register2.php:23 Stack trace: #0 {main} thrown in C:\xampp\htdocs\register2.php on line 23 Quote Link to comment Share on other sites More sharing options...
revraz Posted February 29, 2008 Share Posted February 29, 2008 You using PHP 5? Quote Link to comment Share on other sites More sharing options...
edah527 Posted March 7, 2008 Author Share Posted March 7, 2008 yep 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.