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 } ?> Link to comment https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/ 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. Link to comment https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/#findComment-474208 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(); } ?> Link to comment https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/#findComment-475392 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 Link to comment https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/#findComment-479682 Share on other sites More sharing options...
revraz Posted February 29, 2008 Share Posted February 29, 2008 You using PHP 5? Link to comment https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/#findComment-479716 Share on other sites More sharing options...
edah527 Posted March 7, 2008 Author Share Posted March 7, 2008 yep Link to comment https://forums.phpfreaks.com/topic/92545-phpmysql-registration-form/#findComment-486373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.