justravis Posted September 9, 2008 Share Posted September 9, 2008 The print_r proves there is 'confirm' session var, but it doesnt test true. #Test #print_r($_SESSION); if($_SESSION[confirm]) { "echo <span class=hi>$_SESSION[confirm]</span>"; } I know...this question deducts cool pts...Thanks. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 9, 2008 Share Posted September 9, 2008 What is in $_SESSION['confirm']? Get in the habbit of putting '' around element names. Instead of: $_SESSION[confirm] It should be: $_SESSION['confirm'] Try using the isset() function. if(isset($_SESSION['confirm'])){ echo "It is set!"; } Quote Link to comment Share on other sites More sharing options...
justravis Posted September 9, 2008 Author Share Posted September 9, 2008 'confirm' is a string. I should have mentioned I tried isset() before posting, but OF COURSE it works now!!! Winning Code: if(isset($_SESSION['confirm'])) { "echo <span class=hi>$_SESSION['confirm']</span>"; } W if(isset($_SESSION['confirm'])) { echo "<span class=hi>$_SESSION['confirm']</span>"; } Resulted in: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING ..BUT this suddenly works now too..wtf?!?! if($_SESSION[confirm]) { echo "<span class=hi>$_SESSION[confirm]</span>"; } THANKS!!!! Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 9, 2008 Share Posted September 9, 2008 If you are to echo an array, then you do it like so: echo "<span class='hi'>{$_SESSION['confirm']}</span>"; OR echo "<span class='hi'>".$_SESSION['confirm']."</span>"; Also, that first code you posted should fail. Use one of the above. Keep using apostrophes when referring to a key in the array. 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.