Parse error: syntax error, unexpected '}' in C

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php001
Forum Newbie
Posts: 10
Joined: Tue Jul 03, 2012 12:19 pm

Parse error: syntax error, unexpected '}' in C

Post by php001 »

How many causes that make this error occur? I check my code, but there is no syntax error, can anyone help me to review the code?
Here is my code......

Code: Select all

session_start();
if(!session_is_registered(username)){
header("location:main_login.php");
}
session_register('admin');

include ("connect.php");
$userName = $_SESSION['admin'];

if($_SESSION['admin']!= null)
{
?>

<html>
blablablablablabla
blablablablablabla
blablablablablabla
</html>

<?php//invalid login
}
else
{
	echo "<script language='javascript'>alert ('Invalid login')</script>";
	echo "<script language='javascript'>window.location='login.php'</script>";
}
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Parse error: syntax error, unexpected '}' in C

Post by Christopher »

Very strange, but I think the problems is in this line:

Code: Select all

<?php//invalid login
The problem is that there is no space between "<?php" and "//invaid login".
(#10850)
php001
Forum Newbie
Posts: 10
Joined: Tue Jul 03, 2012 12:19 pm

Re: Parse error: syntax error, unexpected '}' in C

Post by php001 »

Is that comment also affect the code?
I deleted the comment but it can't log in successfully, it link to log in page although I typed the right username and password.
php001
Forum Newbie
Posts: 10
Joined: Tue Jul 03, 2012 12:19 pm

Re: Parse error: syntax error, unexpected '}' in C

Post by php001 »

I solve this problems by using two method, one is delete the comment, another way is put the space and the problems is solved. Thank so much!
Post Reply