Jump to content


syntax error

  • Please log in to reply
2 replies to this topic

#1 cspgsl

  • Members
  • PipPip
  • Member
  • 26 posts
  • LocationMalagash Nova Scotia

Posted 22 June 2006 - 08:00 PM

the following error is returned from the code below

Parse error: syntax error, unexpected '<' in ....line 19

the problem is between the <span></span>tags

darned if i can see it... i'm too new

if ($_SESSION['loggedin'] === true):
    //do nothing
elseif (remembereduser()):

function render_login_form() {
    global $form;
    $attribs = array();
    require_once "HTML/QuickForm.php";
    $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'],"",NULL,TRUE); 
    $form->addElement("header", "","Login here");
    $form->addElement("hidden","freshtest", getfreshtestid());

<span style="color:darkblue;"<?Hello :
=empty($_SESSION['bsd_username'])?>" We'd really like to learn your name.  Please login or register" : $_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" >

$_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" ?</span>
    $form->addElement("text", "username", "Username:", $attribs);    
    $form->addElement("password", "pwd", "Password:", $attribs);
    $form->addElement("checkbox", "rememberme", "", "Remember me", $attribs);
    $buttons[] = &HTML_QuickForm::createElement("reset", "reset", "Clear"); 
    $buttons[] = &HTML_QuickForm::createElement("submit", "submit", "Login");
    $form->addGroup($buttons, null, null, " "); 
    $form->addElement("link", "","", FULLPATH."?action=forgottenpassword","Forgotten your password?", $attribs);
    $form->addRule("username", "You must supply a username", "required");
    $form->addRule("pwd", "You must supply a password", "required");
    $form->registerRule('freshtest', 'callback', 'isfreshsubmission');
    $form->registerRule('passwordverify', 'callback', 'verifypassword');
    $form->addRule("freshtest", "You cannot use the backbutton to login", "freshtest");
    $form->addRule("pwd", "Either the username or password is incorrect", "passwordverify");        
    if ($form->validate()):
        return $form->process("login");

        $contents = '<div class="loginform">'. $form->tohtml().'</div>';
        require_once "template.php";
function login($value=null){
    global $form;
    $_SESSION['loggedin'] = true;
    $_SESSION['username'] = $form->exportvalue("username");
    $rm = &$form->getelement("rememberme");
function setrememberme($state) {
    global $db, $dbusertable;
    if ($state === true):
        $str =  "setting oookie";
        $expiry = time() + 31536000;
        $dbexpiry = $expiry;
        $str =  "deleting cookie";
        $expiry = time()  -3600;
        $dbexpiry = null;
    $result = $db->query("update $dbusertable set rememberme=? where username=?", array($dbexpiry, $_SESSION['username']));
    setcookie("bsd_username", $_SESSION['username'], $expiry);
function remembereduser() {
    global $db, $dbusertable;
    if (!isset($_COOKIE['bsd_username'])) return false;
    $num = $db->getOne("Select count(*) from $dbusertable where username=? and rememberme > ?", array (trim($_COOKIE['bsd_username']), time()));
    return ($num == 1);
function loginremembereduser() {
    $_SESSION['loggedin'] = true;
    $_SESSION['username'] = trim($_COOKIE['bsd_username']);
function verifypassword($value) {
    //note you cannot use this for crypted passwords, but md5 passwords work ok.
    global $form, $db, $dbusertable;
    $submittedusername = trim($form->exportvalue("username"));
    $num = $db->getOne("select count(*) as cnt from $dbusertable where username=? and pwd=?", array($submittedusername, md5($pwd)));
    return  ($num == 1);
function logout() {
    unset ($_SESSION['username']);
    unset ($_SESSION['loggedin']);


#2 freakus_maximus

  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 22 June 2006 - 08:21 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<span style="color:darkblue;"<?Hello :
=empty($_SESSION['bsd_username'])?>" We'd really like to learn your name. Please login or register" : $_SESSION['bsd_username'] . " ( ".$_SESSION['bsd_profession'] .")" >

Quite a few things here -

I cannot tell if you meant to exit php prior to the <span> tag, if you did you are missing "?>" before the tag. If you didn't mean to exit php, then you do not have any echo command to actually produce the tag. This is your unexpected "<" error.

Looks like you are missing a ">" to close your <span> tag.

Also, it looks like you will receive additional errors, becuase it does not appear that you are using the echo command after you move back into php. You have "<?Hello :". But since you never exited php I am not sure what you are attempting there.

Depending on what you are wanting to do, you need to review this whole section, but it could be that you need to just setup your echo commands.

Hope that helps!

#3 cspgsl

  • Members
  • PipPip
  • Member
  • 26 posts
  • LocationMalagash Nova Scotia

Posted 23 June 2006 - 06:28 PM

it was really just a matter of closing and reopening the php tags. it then worked fine. so simple... thanks for the response

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users