cspgsl Posted June 22, 2006 Share Posted June 22, 2006 the following error is returned from the code belowParse error: syntax error, unexpected '<' in ....line 19the problem is between the <span></span>tagsdarned if i can see it... i'm too new[code] <?if ($_SESSION['loggedin'] === true): //do nothingelseif (remembereduser()): loginremembereduser();else: $form=""; render_login_form();endif;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'] .")" ></span>$_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"); else: $contents = '<div class="loginform">'. $form->tohtml().'</div>'; require_once "template.php"; exit; endif;}function login($value=null){ global $form; unset($_SESSION['freshtest']); $_SESSION['loggedin'] = true; $_SESSION['username'] = $form->exportvalue("username"); $rm = &$form->getelement("rememberme"); setrememberme($rm->getchecked()); }function setrememberme($state) { global $db, $dbusertable; if ($state === true): $str = "setting oookie"; $expiry = time() + 31536000; $dbexpiry = $expiry; else: $str = "deleting cookie"; $expiry = time() -3600; $dbexpiry = null; endif; $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']); setrememberme(true);} function verifypassword($value) { //note you cannot use this for crypted passwords, but md5 passwords work ok. global $form, $db, $dbusertable; $pwd=trim($value); $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']); setrememberme(false);}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12666-syntax-error/ Share on other sites More sharing options...
freakus_maximus Posted June 22, 2006 Share Posted June 22, 2006 [!--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'] .")" ></span>[/quote]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! Quote Link to comment https://forums.phpfreaks.com/topic/12666-syntax-error/#findComment-48586 Share on other sites More sharing options...
cspgsl Posted June 23, 2006 Author Share Posted June 23, 2006 it was really just a matter of closing and reopening the php tags. it then worked fine. so simple... thanks for the response Quote Link to comment https://forums.phpfreaks.com/topic/12666-syntax-error/#findComment-48889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.