Forum Moderators: coopster

Message Too Old, No Replies

what exactly is wrong with this?

parse error, unexpected '{' on line 5

         

mylungsarempty

2:30 am on Dec 31, 2003 (gmt 0)

10+ Year Member



<?

session_start();

if((!$_SESSION[username]) && (isset($_POST[username])) && (isset($_POST[password])) {

$username = $_POST[username];
$userpass = $_POST[userpass];

$_SESSION[username] = $username;
$_SESSION[userpass] = $userpass;

} else {

$username = $_SESSION[username];
$userpass = $_SESSION[userpass];

}

?>

...why is the bracket "unexpected"?

[edited by: mylungsarempty at 2:45 am (utc) on Dec. 31, 2003]

mylungsarempty

2:38 am on Dec 31, 2003 (gmt 0)

10+ Year Member



i cannot find anything syntactically wrong with this and i'm getting so frustrated. what is wrong with that? am i going crazy?

sysdomatic

2:44 am on Dec 31, 2003 (gmt 0)

10+ Year Member




<?
session_start();

if((!$_SESSION['username']) && (isset($_POST['username']) && isset($_POST['password'])) {

You seem to be missing a closing bracket in the second part of this statement; maybe try changing to this:

if((!$_SESSION['username']) && (isset($_POST['username'])) && (isset($_POST['password']))) {

mylungsarempty

2:49 am on Dec 31, 2003 (gmt 0)

10+ Year Member



ahhhhhh thankyou so much -- PHP can be so frustrating when you're a novice.

uncle_bob

3:30 am on Dec 31, 2003 (gmt 0)

10+ Year Member



A simple trick is to count along the backets rather than trying to match them all up, adding one for a left bracket, and subtracting one for a right, then if you don't end with zero, you've missed bracket somewhere


if((!$_SESSION['username']) && (isset($_POST['username']) && isset($_POST['password']))
1 2 .................... 1 .. 2 ... 3 ................ 2 ....... 3 ................ 2 1