Darkmatter5 Posted July 11, 2008 Share Posted July 11, 2008 Here's my code <?php if(isset($_SESSION['member_id'])) { echo "You are currently logged in as<strong>" .$ec->current_user(). "<div class='main_text'>Please register for an account or login for restricted usage.</div><br /><br />"; } else { echo "You are currently not logged in. <div class='main_text'></div><br /><br />"; } ?> Now here's my output: "Welcome to E-Cabinet! xxx.xxxYou are currently logged in as Please register for an account or login for restricted usage." It should be: Welcome to E-Cabinet! You are currently logged in as xxx.xxx Please register for an account or login for restricted usage." Any ideas? Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/ Share on other sites More sharing options...
DarkWater Posted July 11, 2008 Share Posted July 11, 2008 1) I don't see a closing strong tag. </strong> 2) What's the code for $ec->current_user()? 3)? Where do you echo "Welcome to E-Cabinet!"? Show some more code please. Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/#findComment-587779 Share on other sites More sharing options...
sasa Posted July 11, 2008 Share Posted July 11, 2008 in function current_user change echo to return Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/#findComment-587828 Share on other sites More sharing options...
Darkmatter5 Posted July 11, 2008 Author Share Posted July 11, 2008 I fixed the no </strong> code. Here's current_user() function current_user() { include 'library/config.inc.php'; require('C:\wamp\www\library\opendb.php'); $pagedb = "members"; $member_id = $_SESSION['member_id']; $query = mysql_query("SELECT mem_username FROM " .$dbname. "." .$pagedb. " WHERE member_id = '" .$member_id. "' ") or die(mysql_error()); $current_user = mysql_fetch_array($query); echo $current_user['mem_username']; } Here's the code that shows "Welcome to E-Cabinet" <div>Welcome to E-Cabinet! <?php if(isset($_SESSION['member_id'])) { echo "You are currently logged in as<strong>" .$ec->current_user(). "</strong><div class='main_text'>Please register for an account or login for restricted usage.</div><br /><br />"; } else { echo "You are currently not logged in. <div class='main_text'></div><br /><br />"; } ?> </div> Thanks! Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/#findComment-587829 Share on other sites More sharing options...
DarkWater Posted July 11, 2008 Share Posted July 11, 2008 Change: echo $current_user['mem_username']; To: return $current_user['mem_username']; Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/#findComment-587832 Share on other sites More sharing options...
Darkmatter5 Posted July 11, 2008 Author Share Posted July 11, 2008 it's working! Thanks all!! Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/#findComment-587842 Share on other sites More sharing options...
craygo Posted July 11, 2008 Share Posted July 11, 2008 Don't forget to mark as solved Link to comment https://forums.phpfreaks.com/topic/114305-help-with-strange-output-of-echo-command/#findComment-587846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.