Page 1 of 1

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

Posted: Tue Jul 03, 2012 12:25 pm
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>";
}
?>

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

Posted: Tue Jul 03, 2012 12:51 pm
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".

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

Posted: Tue Jul 03, 2012 8:26 pm
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.

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

Posted: Tue Jul 03, 2012 10:00 pm
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!