Jump to content

[SOLVED] parse error


freddyw

Recommended Posts

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");
	}


}


?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.