Two parse errors and one smaller issue with user accounts.
Two parse errors and one smaller issue with user accounts.
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.
[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...
Reason: code tags...
Re: Two parse errors and one smaller issue with user account
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
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?
Re: Two parse errors and one smaller issue with user account
That should be
[syntax=php]
$_SESSION['username'] = htmlentities($_POST['username']);
[/syntax]
[syntax=php]
$_SESSION['username'] = htmlentities($_POST['username']);
[/syntax]
Re: Two parse errors and one smaller issue with user account
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]
Re: Two parse errors and one smaller issue with user account
Could you post your full code?
It might be that you've forgotten a } somewhere
It might be that you've forgotten a } somewhere
Re: Two parse errors and one smaller issue with user account
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.
Re: Two parse errors and one smaller issue with user account
[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 !
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 !
Re: Two parse errors and one smaller issue with user account
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]
Re: Two parse errors and one smaller issue with user account
Your missing a $ in your {path} should be {$path}
Thats the only error i can spot.
Thats the only error i can spot.
Re: Two parse errors and one smaller issue with user account
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
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
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 ?