Register Page Parse error: syntax error, unexpected '}'

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 1282 Views - Last Post: 09 March 2015 - 09:07 AM Rate Topic: -----

#1 rich_hemmings   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 88
  • Joined: 05-November 08

Register Page Parse error: syntax error, unexpected '}'

Posted 06 March 2015 - 11:24 AM

Hi Guys hope you're all well I have found some simple PHP code to help me to create a register user and to them them log in from here (https://www.youtube.com/watch?v=yp_gH3zPfbo)

This is the code so far

<!DOCTYPE html> 
<html> 
	<head> 
    	<title>Richard Hemmings  </title>
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0"> 
        <link href = "css/bootstrap.min.css"rel = "stylesheet"> 
        <link href = "css/stylesheet.css" rel = "stlesheet"> 
        
        </head>
        <body>
        
   			<div class = "navbar navbar-inverse navbar-static-top">
            	<div class = "contrainer"> 
                
 <?php
include('inc/header.php'); 
require('connection_db.php'); 

if(isset($_post ['submit'])) {
	
} else {
	
$form = <<<EOT
<form action='register.php' method="POST"> 
First Name: <input type="text" name="name" /><br /> 
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <imput type="text" name="email2" /><br />
Password: <input type="password" name"pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
EOT; 
}













?>




                
    
  

           
                
        <div class = "navbar navbar-default navbar-fixed-bottom"> 
                
                <div class = "container"> 
                	<P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P> 
                
                </div> 
                
                </div>
             
                
                
                
                
                
                
                
       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src = "js/bootstrap/js" ></script>
       
		
		
        
        </body>
        
        </html> 
		
		
		



When I run it on my local host I'm getting this following error


Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end (T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) inC:\xampp\htdocs\register.php on line 85


Can anyone help me with this please

Thanks

Rich

Is This A Good Question/Topic? 0
  • +

Replies To: Register Page Parse error: syntax error, unexpected '}'

#2 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6876
  • View blog
  • Posts: 31,671
  • Joined: 10-May 07

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 06 March 2015 - 11:28 AM

I've never fond of the until EOF or similar. Why not do something like the following :

$form =  '<form action='register.php' method="POST"> 
First Name: <input type="text" name="name" /><br /> 
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <imput type="text" name="email2" /><br />
Password: <input type="password" name"pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />';


I'm curious to the logic though. You have an if conditional that you have no action taken, then in your else you set a value to $form & then never use it. What exactly is the process here?

Also, why do you have SO MANY blank lines?
Was This Post Helpful? 0
  • +
  • -

#3 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 06 March 2015 - 11:31 AM

Line #32 is the problem. See this section in the PHP manual for an explanation as to why it's a problem: heredoc syntax.

P.S.
The problem won't actually show up in the DIC code block.
(It trims white-spaces of the ends of lines...)

View Postno2pencil, on 06 March 2015 - 06:28 PM, said:

I've never fond of the until EOF or similar. Why not do something like the following :

I'd be more inclined to just break out of the PHP parsing. Usually turns out cleaner, really, if you are doing PHP/HTML infusion code anyway.

This post has been edited by Atli: 06 March 2015 - 11:32 AM

Was This Post Helpful? 1
  • +
  • -

#4 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6876
  • View blog
  • Posts: 31,671
  • Joined: 10-May 07

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 06 March 2015 - 11:34 AM

View PostAtli, on 06 March 2015 - 01:31 PM, said:

View Postno2pencil, on 06 March 2015 - 06:28 PM, said:

I've never fond of the until EOF or similar. Why not do something like the following :

I'd be more inclined to just break out of the PHP parsing. Usually turns out cleaner, really, if you are doing PHP/HTML infusion code anyway.

I don't disagree with this statement. Though OP maybe in progress & there will be more code to come, as per my question about the logic of this program.

Though it certainly is cleaner to set specific values & then echo them out within the html of the form, relative to this question.
Was This Post Helpful? 0
  • +
  • -

#5 rich_hemmings   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 88
  • Joined: 05-November 08

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 03:49 AM

Hi Guys, I posted a few days ago about creating a register page to let my users regsister and log in, into my website. I'm following a very good tutorial on youtube https://www.youtube....h?v=yp_gH3zPfbo here.

When I now run the page I'm getting the following error, I knew I would but I dont know how to get around this problem
Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\register.php on line 36

This is my code so far

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Richard Hemmings  </title> 
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0"> 
        <link href = "css/bootstrap.min.css"rel = "stylesheet"> 
        <link href = "css/stylesheet.css" rel = "stlesheet"> 
    </head> 
    <body> 
        <div class = "navbar navbar-inverse navbar-static-top"> 
            <div class = "contrainer"> 
<?php 
include('inc/header.php'); 
require('connection_db.php');  
if(isset($_post ['submit'])) 
{ 
   // Peform the berification of the nation  
    
   $email1 = $_POST['email1'];  
   $email2 = $_POST['email2'];  
   $pass1 = $_POST['pass1'];  
   $pass2 = $_POST['pass2'];  
    
   if($email1 == $email2) { 
         if($pass1 == $pass2) { 
            // All good, Please carry on!.  
             
         
         
        }else{  
                echo "sorry, your passwords do not match. <br />";  
                exit();  
                 
        } 
         
   }else{  
           echo "Sorry your email's do not match, please try again<br /><"  
  } 
else 
{ 
    echo  <<<EOT 
                <form action='register.php' method="POST"> 
                    First Name: <input type="text" name="name" /><br /> 
                    Last Name: <input type="text" name="lname" /><br /> 
                    Username: <input type="text" name="uname" /><br /> 
                    Email: <input type="text" name="email1" /><br /> 
                    Confirm Email: <imput type="text" name="email2" /><br /> 
                    Password: <input type="password" name"pass1" /><br /> 
                    Confirm Password <input type="password" name="pass2" /><br /> 
                    <input type="submit" value="Register" name="Submit" /><br /> 
EOT; 
// the preceding line must have NO leading white-space of any kind 
} 

?> 




                 
     
   

            
                 
        <div class = "navbar navbar-default navbar-fixed-bottom">  
                 
                <div class = "container">  
                    <P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P>  
                 
                </div>  
                 
                </div> 
              
                 
                 
                 
                 
                 
                 
                 
       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src = "js/bootstrap/js" ></script> 
        
         
         
         
        </body> 
         
        </html>

Any help would be appreciated

Thanks in advance

Rich
Was This Post Helpful? 0
  • +
  • -

#6 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 04:37 AM

Line 37 in that code is missing the semi-colon. Though why that would cause an error on line 36 I don't know.

Your use of $_post ['submit'] is also invalid. $_POST and $_post are not the same things; it's case-sensitive.
Was This Post Helpful? 0
  • +
  • -

#7 rich_hemmings   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 88
  • Joined: 05-November 08

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 05:22 AM

ive updated the code

this is it

<!DOCTYPE html>
<html>
    <head>
        <title>Richard Hemmings  </title>
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0">
        <link href = "css/bootstrap.min.css"rel = "stylesheet">
        <link href = "css/stylesheet.css" rel = "stlesheet">
    </head>
    <body>
        <div class = "navbar navbar-inverse navbar-static-top">
            <div class = "contrainer">
<?php
include('inc/header.php');
require('connection_db.php'); 
if(isset($_post ['submit']));
{
   // Peform the berification of the nation 
   
   $email1 = $_POST['email1']; 
   $email2 = $_POST['email2']; 
   $pass1 = $_POST['pass1']; 
   $pass2 = $_POST['pass2']; 
   
   if($email1 == $email2) {
	 	if($pass1 == $pass2) {
			// All good, Please carry on!. 
					}else{ 
				echo "sorry, your passwords do not match. <br />"; 
				exit(); 			
		}
		   }else{ 
   		echo "Sorry your email's do not match, please try again<br /><";
//  }else{ 
    echo  <<<EOT
                <form action='register.php' method="POST">
                    First Name: <input type="text" name="name" /><br />
                    Last Name: <input type="text" name="lname" /><br />
                    Username: <input type="text" name="uname" /><br />
                    Email: <input type="text" name="email1" /><br />
                    Confirm Email: <imput type="text" name="email2" /><br />
                    Password: <input type="password" name"pass1" /><br />
                    Confirm Password <input type="password" name="pass2" /><br />
					<input type="submit" value="Register" name="Submit" /><br />
EOT;
// the preceding line must have NO leading white-space of any kind
}
?>
<div class = "navbar navbar-default navbar-fixed-bottom"> 
                
                <div class = "container"> 
                	<P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P> 
                
                </div> 
                
                </div>           
       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src = "js/bootstrap/js" ></script>
  </body>
        </html> 


the following error i'm getting


Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\register.php on line 58
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6876
  • View blog
  • Posts: 31,671
  • Joined: 10-May 07

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 05:31 AM

** Topics merged **

Please don't open a new topic every time you have a syntax error.
Was This Post Helpful? 0
  • +
  • -

#9 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 05:49 AM

Line 15 has two problems, and by commenting line 33 you leave a block open when the file ends.
Was This Post Helpful? 0
  • +
  • -

#10 rich_hemmings   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 88
  • Joined: 05-November 08

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 07:18 AM

hey guys I have manafed to sort out the issue out with the PHP from an earier post that I posted earlier today but now, when I run the page on my local host, the form does not show at all. Can anyone help me as to why this is the problem?..

<!DOCTYPE html>
<html>
    <head>
        <title>Richard Hemmings  </title>
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0">
        <link href = "css/bootstrap.min.css"rel = "stylesheet">
        <link href = "css/stylesheet.css" rel = "stlesheet">
    </head>
    <body>
        <div class = "navbar navbar-inverse navbar-static-top">
            <div class = "contrainer">
<?php
include('inc/header.php');
require('connection_db.php'); 
if(isset($_post ['submit']))
{
   // Peform the berification of the nation 
    
   $email1 = $_POST['email1']; 
   $email2 = $_POST['email2']; 
   $pass1 = $_POST['pass1']; 
   $pass2 = $_POST['pass2']; 
    
   if($email1 == $email2) {
        if($pass1 == $pass2) {
        }else{ 
                echo "sorry, your passwords do not match. <br />"; 
                exit(); 
        }
         echo "Sorry your email's do not match, please try again<br /><";
   }else{ 
        
        $form =  <<<EOT
                <form action='register.php' method="POST">
                    First Name: <input type="text" name="name" /><br />
                    Last Name: <input type="text" name="lname" /><br />
                    Username: <input type="text" name="uname" /><br />
                    Email: <input type="text" name="email1" /><br />
                    Confirm Email: <imput type="text" name="email2" /><br />
                    Password: <input type="password" name"pass1" /><br />
                    Confirm Password <input type="password" name="pass2" /><br />
                    <input type="submit" value="Register" name="Submit" /><br />
EOT;
// the preceding line must have NO leading white-space of any kind
}
}
?>
 
 
 
 
                 
     
   
 
            
                 
        <div class = "navbar navbar-default navbar-fixed-bottom"> 
                 
                <div class = "container"> 
                    <P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P> 
                 
                </div> 
                 
                </div>
              
                 
                 
                 
                 
                 
                 
                 
       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src = "js/bootstrap/js" ></script>
        
         
         
         
        </body>
         
        </html> 


Any help would be brilliant

Richard
Was This Post Helpful? 0
  • +
  • -

#11 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 07:22 AM

** Topics merged **

Please stop opening new threads on this subject. We don't need a new thread for ever new issue that pops up in this same small script.
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6876
  • View blog
  • Posts: 31,671
  • Joined: 10-May 07

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 07:22 AM

What is going on with lines 45 & 46?
Was This Post Helpful? 0
  • +
  • -

#13 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 07:25 AM

Yea the lineup of your if-else clauses seems to be somewhat off. Make sure your form code is where it's supposed to be within the logic.
Was This Post Helpful? 0
  • +
  • -

#14 rich_hemmings   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 88
  • Joined: 05-November 08

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 07:57 AM

well i have looked at it and the form is still not showing
Was This Post Helpful? 0
  • +
  • -

#15 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6876
  • View blog
  • Posts: 31,671
  • Joined: 10-May 07

Re: Register Page Parse error: syntax error, unexpected '}'

Posted 09 March 2015 - 08:19 AM

What error are you currently getting? What does your error logs report?

It was suggested that you not use EOT, yet you still are.
It has also been suggested that you stop opening new topics to report the next syntax error for us to point out (which ironically is pointed out by the line error number), & yet you still do...

With this many errors, perhaps you need to take a better approach to development, or you need to find a different tutorial. One of these two are causing basic syntax errors, that you can't seem to overcome.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2