Another Login Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Another Login Error

Post by anthony88guy »

I am making a login using sessions, when the user and pass is checked to the database and returns true then Session record their username, and gives permission. Redirected to another page, here is the code of my page.



I get an error on line 55: Parse error: parse error, unexpected $

Can anyone shed any light why it won't work?
Last edited by anthony88guy on Thu May 12, 2005 6:11 pm, edited 2 times in total.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

look closely at line 4 of your posted code. line 3 has { but I don't see the }

phpscott
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

thanks a million, i was looking at the bottom.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Yeah, problems with missing braces always cause the most pain because the parser will always throw an error indicating something's wrong at the bottom of the page.

The solution? Make sure you indent your logic.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

there are several editors outside that will show their sister bracket -- one being PHP Designer 2005.. indending helps too
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that's exactly why I always use this sort of style

Code: Select all

if($somevar)
{
    echo 'something';
}
else
{
    echo 'something else';
}
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Hmm... I prefer a K&R (EDIT-the Rcharacter got munged) style for conditionals:

Code: Select all

if ($bang == 'big') {
    //More stuff
} elseif ($foo == 'lob' && empty($mar)) {
    //Stuff
} else {
    exit;
}
and BSD for functions (which is the style Feyd uses)

Code: Select all

function general_convertChar()
{
    return 0;
}
Bracing styles are a matter of personal preference, but make sure you're consistent.
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

I am pretty new to php, and havent really developed a style to writing my code yet. Thanks again though, my login works. :)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Then now is the time to start. Get into good habits early (I bemoan myself over poorly written code that I still use).
Post Reply