2 Replies - 525 Views - Last Post: 20 July 2011 - 09:43 AM Rate Topic: -----

#1 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Having problems echoing a session variable

Posted 20 July 2011 - 09:24 AM

Hey guys!

I think this is pretty simple but I can't seem to figure out where my disconnect is...

I am storing a session variable from my db, username, and trying to echo it in the top of the login_index....but it keeps say 'Adlan' or 'Balei e' and it doesn't even show the world welcome. If i remove the session username, it does show the 'welcome' ... would anyone be so kind as to point me in the right direction.

<h2 class="star"><span><?php echo('Welcome') & $_SESSION['username'] ; ?></span></h2>



I've also tried
<h2 class="star"><span><?php echo('Welcome') && $_SESSION['username'] ; ?></span></h2>



Any ideas?


[EDIT]

just in case this makes a diff, this is where my variables are initially coming from

$userid=mysql_real_escape_string($userid);
$password=md5(mysql_real_escape_string($password)); 

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username='$userid' AND password='$password'"))){
if(($rec['username']==$userid)&&($rec['password']==$password)){
include "/home/u395388955/public_html/newsession.php";
$_SESSION['username']=$rec['username'];
header ('location: login_index.php');


As always guys, thanks in advance!! :)

This post has been edited by guyfromri: 20 July 2011 - 09:27 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Having problems echoing a session variable

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2982
  • View blog
  • Posts: 10,299
  • Joined: 08-August 08

Re: Having problems echoing a session variable

Posted 20 July 2011 - 09:38 AM

Echo doesn't work like that. Try
echo 'Welcome'.$_SESSION['username'];

Was This Post Helpful? 1
  • +
  • -

#3 guyfromri  Icon User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 817
  • Joined: 16-September 09

Re: Having problems echoing a session variable

Posted 20 July 2011 - 09:43 AM

lol...wow....and here I am blaming it on the way I'm setting the variables. Thanks!!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1