Page 1 of 1

Two parse errors and one smaller issue with user accounts.

Posted: Sun Oct 09, 2011 6:35 pm
by Deer
Hi guys. I've been following the tutorial for user accounts and I recently finished it. When I started to test it out I noticed two large errors and one smaller one. The first of which is this: "Parse error: syntax error, unexpected '{', expecting '(' in /home/username/public_html/register.php on line 17" Here's line 17:
if (empty{$_POST['password']) || empty($_POST['repeat_password'])){ 
The next issue is similar. On the login page I get this message: "Parse error: syntax error, unexpected '[', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/username/public_html/login.php on line 14" and here's line
if(empty(S_POST['password'])){
If anyone could help me out it would be great.

Re: Two parse errors and one smaller issue with user account

Posted: Mon Oct 10, 2011 7:41 am
by icey2k
Deer wrote:Parse error: syntax error, unexpected '{', expecting '(' in /home/username/public_html/register.php on line 17" Here's line 17: if (empty{$_POST['password']) || empty($_POST['repeat_password'])){
You got an { where it should be (.

(empty{$_POST['password'])

Re: Two parse errors and one smaller issue with user account

Posted: Mon Oct 10, 2011 12:21 pm
by Deer
icey2k wrote:
Deer wrote:Parse error: syntax error, unexpected '{', expecting '(' in /home/username/public_html/register.php on line 17" Here's line 17: if (empty{$_POST['password']) || empty($_POST['repeat_password'])){
You got an { where it should be (.

(empty{$_POST['password'])
Thanks! That fixed that and I'm guessing I did something similar on the login page. But after fixing that curly bracket I got this error: Parse error: syntax error, unexpected T_VARIABLE in /home/username/public_html/register.php on line 32

This is line 32:
 $_SESSION['username'] = htmlentities $_POST['username']);
Is it the session part that's causing problems?

Re: Two parse errors and one smaller issue with user account

Posted: Mon Oct 10, 2011 12:32 pm
by icey2k
That should be
$_SESSION['username'] = htmlentities($_POST['username']);

Re: Two parse errors and one smaller issue with user account

Posted: Mon Oct 10, 2011 10:49 pm
by Deer
icey2k wrote:That should be
$_SESSION['username'] = htmlentities($_POST['username']);

Well it seems like a new issue has appeared.

Parse error: syntax error, unexpected '{' in /home/username/public_html/core/init.inc.php on line 12

The odd thing here is that there is no "{" on line 12:
		header('Location: login.php');

Re: Two parse errors and one smaller issue with user account

Posted: Tue Oct 11, 2011 6:01 am
by icey2k
Could you post your full code?

It might be that you've forgotten a } somewhere :-)

Re: Two parse errors and one smaller issue with user account

Posted: Tue Oct 11, 2011 1:05 pm
by Deer
icey2k wrote:Could you post your full code?

It might be that you've forgotten a } somewhere :-)
<?php

session_start();

$exceptions = array('register','login');

$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])),0, -4) ;

if (in_array($page, $exceptions) === false){

	if(isset($_SESSION['username']) === false){
		header{'Location: login.php');
		die();
	}
}



mysql_connect('server ip is entered in the real code', 'example_pass', 'example_pass');
mysql_select_db('username_user_system');

$path = dirname(_FILE_);

include("{path}/inc/user.inc.php");

?>
There you go. I double checked it but couldn't seem to find any errors. But it seems I'm bad at spotting "{" so I might've overlooked something.

Re: Two parse errors and one smaller issue with user account

Posted: Tue Oct 11, 2011 6:08 pm
by jacek
$path = dirname(_FILE_);
should be
$path = dirname(__FILE__);
btw.

And
header{'Location: login.php');
You have a { here where a ( should be. Hard to spot !

Re: Two parse errors and one smaller issue with user account

Posted: Tue Oct 11, 2011 10:32 pm
by Deer
jacek wrote:
$path = dirname(_FILE_);
should be
$path = dirname(__FILE__);
btw.

And
header{'Location: login.php');
You have a { here where a ( should be. Hard to spot !
Hmm. I fixed both of these errors but I'm still getting the error message. All of the brackets are closed it seems, I'm stumped.
<?php

session_start();

$exceptions = array('register','login');

$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])),0, -4) ;

if (in_array($page, $exceptions) === false){

	if(isset($_SESSION['username']) === false){
		header('Location: login.php');
		die();
	}
}



mysql_connect('ip address', 'example_pass', 'example_pass');
mysql_select_db('username_user_system');

$path = dirname(__FILE__);

include("{path}/inc/user.inc.php");

?>

Re: Two parse errors and one smaller issue with user account

Posted: Wed Oct 12, 2011 6:27 am
by icey2k
Your missing a $ in your {path} should be {$path} :-)

Thats the only error i can spot.

Re: Two parse errors and one smaller issue with user account

Posted: Wed Oct 12, 2011 12:32 pm
by jacek
What is the error now ?, the missing $ should not cause a parse error. IT would cause the file not to be included though.

Re: Two parse errors and one smaller issue with user account

Posted: Sat Oct 15, 2011 10:18 pm
by Deer
jacek wrote:What is the error now ?, the missing $ should not cause a parse error. IT would cause the file not to be included though.

Well now I have like 8 different errors though I'm able to get to the register and login pages. The errors messages are just displayed on the page, it's odd.

Re: Two parse errors and one smaller issue with user account

Posted: Sun Oct 16, 2011 11:33 am
by jacek
Deer wrote:Well now I have like 8 different errors though I'm able to get to the register and login pages. The errors messages are just displayed on the page, it's odd.
And what are they ? :)