Two parse errors and one smaller issue with user accounts.

Ask about a PHP problem here.
Post Reply
Deer
Posts: 6
Joined: Sun Oct 09, 2011 2:36 pm

Two parse errors and one smaller issue with user accounts.

Post 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:
[syntax=php]if (empty{$_POST['password']) || empty($_POST['repeat_password'])){ [/syntax]

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
[syntax=php]if(empty(S_POST['password'])){[/syntax]

If anyone could help me out it would be great.
Last edited by jacek on Mon Oct 10, 2011 7:32 pm, edited 1 time in total.
Reason: code tags...
icey2k
Posts: 16
Joined: Mon Jul 04, 2011 4:26 pm

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

Post 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'])
Deer
Posts: 6
Joined: Sun Oct 09, 2011 2:36 pm

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

Post 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:
[syntax=php] $_SESSION['username'] = htmlentities $_POST['username']);[/syntax]

Is it the session part that's causing problems?
icey2k
Posts: 16
Joined: Mon Jul 04, 2011 4:26 pm

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

Post by icey2k »

That should be

[syntax=php]
$_SESSION['username'] = htmlentities($_POST['username']);
[/syntax]
Deer
Posts: 6
Joined: Sun Oct 09, 2011 2:36 pm

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

Post by Deer »

icey2k wrote:That should be

[syntax=php]
$_SESSION['username'] = htmlentities($_POST['username']);
[/syntax]



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:

[syntax=php] header('Location: login.php');[/syntax]
icey2k
Posts: 16
Joined: Mon Jul 04, 2011 4:26 pm

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

Post by icey2k »

Could you post your full code?

It might be that you've forgotten a } somewhere :-)
Deer
Posts: 6
Joined: Sun Oct 09, 2011 2:36 pm

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

Post by Deer »

icey2k wrote:Could you post your full code?

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


[syntax=php]<?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");

?>[/syntax]

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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post by jacek »

[syntax=php]$path = dirname(_FILE_);[/syntax]
should be

[syntax=php]$path = dirname(__FILE__);[/syntax]
btw.

And

[syntax=php]header{'Location: login.php');[/syntax]
You have a { here where a ( should be. Hard to spot !
Image
Deer
Posts: 6
Joined: Sun Oct 09, 2011 2:36 pm

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

Post by Deer »

jacek wrote:[syntax=php]$path = dirname(_FILE_);[/syntax]
should be

[syntax=php]$path = dirname(__FILE__);[/syntax]
btw.

And

[syntax=php]header{'Location: login.php');[/syntax]
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.
[syntax=php]<?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");

?>[/syntax]
icey2k
Posts: 16
Joined: Mon Jul 04, 2011 4:26 pm

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

Post by icey2k »

Your missing a $ in your {path} should be {$path} :-)

Thats the only error i can spot.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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.
Image
Deer
Posts: 6
Joined: Sun Oct 09, 2011 2:36 pm

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

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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 ? :)
Image
Post Reply