Spartan 117 Posted January 19, 2007 Share Posted January 19, 2007 Hello, I am having trouble with echoing the username from a session. I have a session made like this:[code]<?php// username and password sent from signup form$IAmAdmin=$_POST['IAmAdmin'];$mypassword=$_POST['mypassword'];$sql="SELECT * FROM $tbl_name WHERE name='$IAmAdmin' and password ='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"session_register("IAmAdmin");session_register("mypassword");header("location:login_success.php");}else {echo "Wrong Username or Password";}php?>[/code]Here is my echo code:[code] <?php //Echo: Welcome, Username! Logout Link, or Welcome Guest & Login Link $MyName= "Welcome, " $_SESSION['IAmAdmin'] "! <a href="logout.php">Logout</a>"; if (!(isset($_SESSION['IAmAdmin']))) { $MyName=" <font size=\"1\" face=\"Arial\"> Welcome, Guest! Please <a href=\"http://evgclan.net/index.php?option=com_smf&Itemid=41&action=login\">Login</a> Or <a href=\"http://evgclan.net/index.php?option=com_smf_registration&task=register\">Register</a></font>"); } echo ($MyName); ?>[/code]I get an error on this for some reason: "parse error, unexpected T_VARIABLE" I just want it to echo: Welcome Guest Please Login Or Register if there is no session, but if there is I want it to say, Welcome, USERNAME. Logout_LinkCould somebody please help me? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 In the future, post the WHOLE error, with the line.change: $MyName= "Welcome, " $_SESSION['IAmAdmin'] "! <a href="logout.php">Logout</a>";to: $MyName= 'Welcome, '.$_SESSION['IAmAdmin'].'! <a href="logout.php">Logout</a>'; Quote Link to comment Share on other sites More sharing options...
Spartan 117 Posted January 19, 2007 Author Share Posted January 19, 2007 Thank You! I got the username to work without the guest part. But the guest part doesn't work.I put that right under the part that says: " $MyName= "Welcome, " ...[code]if (!(isset($_SESSION['IAmAdmin']))) { $MyName=" <font size=\"1\" face=\"Arial\"> Welcome, Guest! Please <a href=\"http://evgclan.net/index.php?option=com_smf&Itemid=41&action=login\">Login</a> Or <a href=\"http://evgclan.net/index.php?option=com_smf_registration&task=register\">Register</a></font>"); } [/code]Here is the error I get with that: [quote]Parse error: parse error, unexpected ')' in /mnt/w0000/d07/s24/b02a01ae/www/new/admin/login.php on line 71[/quote]How do I do this?Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 You have a ) at the end of that line, it obviously doesn't belong. Quote Link to comment Share on other sites More sharing options...
Spartan 117 Posted January 19, 2007 Author Share Posted January 19, 2007 [quote author=jesirose link=topic=123149.msg508622#msg508622 date=1169220697]You have a ) at the end of that line, it obviously doesn't belong.[/quote]oops, sorry for asking such a foolish question :-[Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 No problems. You might want to check out an editor like textpad which does syntax highlighting, helps catch those things. Quote Link to comment 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.