MasterACE14 Posted September 29, 2007 Share Posted September 29, 2007 Evening Folks, I'm having a little trouble getting a function to work properly within a echo. It seems to me that this problem is something really simple, but I just can't quite put my finger on it :-\. The function does execute within the echo, but its being displayed in the wrong order. I dont know whether it is a CSS problem, HTML problem or a PHP problem, or all of the above. Any help is greatly Appreciated! Here's the echo: <!-- Left Column --> <div id = "leftcolumn"> <?php echo '<span><b>Name</b>' . player_table("username") . ' </span>'; ?> </div> this is displaying: ACEName when it should really be more like this: Name ACE Here is the CSS code for the span tag: /* spacing */ span { word-spacing: 30px } Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/ Share on other sites More sharing options...
sasa Posted September 29, 2007 Share Posted September 29, 2007 can we see player_table function Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-357765 Share on other sites More sharing options...
MasterACE14 Posted September 29, 2007 Author Share Posted September 29, 2007 // Select fields from the user table function player_table($select) { if (!isset($_SESSION['playerid'])) { // Destroy the session session_destroy(); // Automatically redirect to the homepage header("Location: index.php?page=home"); } $where = $_SESSION['playerid']; $rs = mysql_connect( "localhost", "ace_ACE", "*****" ); $rs = mysql_select_db( "ace_cf" ); // SQL query for all entries in descending order $sql = "SELECT `" . $select . "` FROM `cf_users` WHERE `id`='" . $where . "' LIMIT 1"; $rs = mysql_query( $sql ) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); // This gets the data from the result resource $query = mysql_result($rs,0,0); echo $query; }; Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-357767 Share on other sites More sharing options...
sasa Posted September 29, 2007 Share Posted September 29, 2007 in function change last line echo $query; to return $query; Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-357770 Share on other sites More sharing options...
MasterACE14 Posted September 29, 2007 Author Share Posted September 29, 2007 Still does the same thing Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-357771 Share on other sites More sharing options...
suma237 Posted September 29, 2007 Share Posted September 29, 2007 im not sure about it.Check this echo $query; };----WHY THIS SEMICOLON? Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-357774 Share on other sites More sharing options...
sasa Posted September 29, 2007 Share Posted September 29, 2007 Still does the same thing are you shure to save changes in function in your 1st code echo statesment first build string for output in building string first call function (it print name on screen) and use what function return (in 1st code nothing) after that print on page using '' for name Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-357779 Share on other sites More sharing options...
MasterACE14 Posted September 30, 2007 Author Share Posted September 30, 2007 I got it working now Thanks guys Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/71139-solved-using-a-function-within-a-echo/#findComment-358198 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.