Click here to Skip to main content
14,977,302 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I keep getting this error
Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in C:\Xampp\htdocs\webtech\coursework\chapter07\game-intro.php on line 47
. How do i fix it?
Here is my code:

HTML
  1  <html>
  2  <head>
  3  	<title>gameIntro</title>
  4  	<link rel ="stylesheet" type="text/css" href="sample.css">
  5  </head>
  6  <body>
  7  
  8  	<?php
  9  	
 10  			$charName = $_POST['charName'];
 11  			$charType = $_POST['charType'];
 12  			$healthTokens = $_POST['healthTokens'];
 13  			$expTokens = $_POST['expTokens'];
 14  			$supplyTokens = $_POST['supplyTokens'];
 15              $userPassword = $_POST['userPassword'];
 16  			
 17  	        $userPassword = strtolower($userPassword);
 18  			
 19  		    $goldSpent = $healthTokens / 10 + $expTokens / 2 + $supplyTokens / 25;
 20  				
 21  			if ($userPassword == "php123")
 22  			
 23  			{
 24  				print("<h1>You have created $charName the $charType!</h1>");
 25  				print("<p>$charName has $healthTokens health tokens,
 26  							$expTokens experience tokens, and 
 27  							$supplyTokens supply tokens.</p>");
 28  			        print("<p>$charName has spent $goldSpent gold pieces.</p>");
 29  			}
 30  			
 31  			else
 32  			
 33  			    print("<p>Sorry! That password is NOT correct! Please try again.</p>);
 34  				
 35      ?>
 36  
 37  </body>
 38  </html>


What I have tried:

I keep trying to see if I am putting braces in the wrong space but I can't find anything wrong.
Posted
Updated 29-Sep-20 0:43am
v2
Comments
Afzaal Ahmad Zeeshan 28-Sep-20 23:24pm
   
I think the problem is being caused by the program that is saving your file; it might not be appending an EOF symbol before flushing the stream to a file.

1 solution

try to replace:
PHP
print("<p>Sorry! That password is NOT correct! Please try again.</p>);

with:
PHP
print("<p>Sorry! That password is NOT correct! Please try again.</p>");
//                           pay attention to the double quote here ^
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900