freddyw Posted September 3, 2009 Share Posted September 3, 2009 im recieving: Parse error: parse error in C:\wamp\www\register2.php on line 63 line 63 is the closing php tag can anyone see why? <?php if(isset($_POST['first_name'])){ $firstname = pg_escape_string($_POST['firstname']); $lastname = pg_escape_string($_POST['lastname']); $username = pg_escape_string($_POST['username']); $password = pg_escape_string($_POST['password']); $verify = pg_escape_string($_POST['verify']); if($password != $verify) { die ('Sorry, The passwords you entered didn\'t match<br>Please use your browsers back button to try again'); } if ( ( !$firstname) or (!$lastname) or (!$username) or (!$password)) { $form = "Please fill the fields below."; $form.="<form action=\"$self\""; $form.="method=\"post\">First Name: "; $form.="<input type =\"text\"name=\"firstname\""; $form.="value=\"$firstname\"><br>Last Name: "; $form.="<input type =\"text\"name=\"lastname\""; $form.="value=\"$lastname\"><br>Username: "; $form.="<input type =\"text\"name=\"username\""; $form.="value=\"$username\"><br>Paswword: "; $form.="<input type =\"text\"name=\"password\""; $form.="value=\"$password\"><br>Verify Password: "; $form.="<input type =\"text\"name=\"verify\""; $form.="value=\"$verify\"><br>"; $form.="<input type =\"submit\" value =\"Submit\">"; $form.="</form>"; echo ( $form ); } else { $conn = @mysql_connect( "localhost", "root", "") or die ("could not connect to mysql"); $db = @mysql_select_db ( "site_table", $conn ) or die ("could not select databse"); $sql = "insert into users (fist_name,last_name,user_name,password) values (\"$firstname\",\"$lastname\",\"$username\",password(\"$password\") )"; $result = @mysql_query ($sql, $conn) or die ("could not execute query"); if ($result) { echo ("Welcome $firstame you are registered as $username"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/173038-solved-parse-error/ Share on other sites More sharing options...
akitchin Posted September 3, 2009 Share Posted September 3, 2009 when the error is on the closing PHP tag, usually it means there is a mis-matched brace in your code. a brace is also known as a curly bracket. indeed, you forget to close your initial if() statement block, so PHP is not expecting your code to end. Quote Link to comment https://forums.phpfreaks.com/topic/173038-solved-parse-error/#findComment-912038 Share on other sites More sharing options...
freddyw Posted September 3, 2009 Author Share Posted September 3, 2009 Thanks alot. Can't believed i missed that. can anyone see why im now recieing all these messages? Notice: Undefined variable: verify in C:\wamp\www\register2.php on line 13 Notice: Undefined variable: password in C:\wamp\www\register2.php on line 13 Notice: Undefined variable: firstname in C:\wamp\www\register2.php on line 19 Notice: Undefined variable: self in C:\wamp\www\register2.php on line 24 Notice: Undefined variable: firstname in C:\wamp\www\register2.php on line 27 Notice: Undefined variable: lastname in C:\wamp\www\register2.php on line 29 Notice: Undefined variable: username in C:\wamp\www\register2.php on line 31 Notice: Undefined variable: password in C:\wamp\www\register2.php on line 33 Notice: Undefined variable: verify in C:\wamp\www\register2.php on line 35 Quote Link to comment https://forums.phpfreaks.com/topic/173038-solved-parse-error/#findComment-912042 Share on other sites More sharing options...
akitchin Posted September 3, 2009 Share Posted September 3, 2009 it's because those variables are undefined, but you use them in conditionals and plug them into a string without checking if they're set first anyway. notices in general will not break any scripts (not strictly speaking at any rate - they could tip you off to any indirect messing up), but they point out places that your code could certainly be better. in this case, before using any undefined variables, you should check if they exist. if you want to have notices turned off, you can lower your error_reporting level using that function. Quote Link to comment https://forums.phpfreaks.com/topic/173038-solved-parse-error/#findComment-912046 Share on other sites More sharing options...
Daniel0 Posted September 3, 2009 Share Posted September 3, 2009 If you had used a proper indentation style you would have seen the parse error immediately. There is a reason why such styles exists. http://en.wikipedia.org/wiki/Indent_style The most popular of those are K&R and Allman. There is also the ZF style. Quote Link to comment https://forums.phpfreaks.com/topic/173038-solved-parse-error/#findComment-912053 Share on other sites More sharing options...
freddyw Posted September 3, 2009 Author Share Posted September 3, 2009 well thanks to both of you. indentation, i know, is one of my many weaknesses in programming. However, i removed parse error, error reporting and when i fill in the registration from, the form resets, and doesnt echo anything. I check the database and the user isn't enetered. Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/173038-solved-parse-error/#findComment-912055 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.