hello all hope all well

I'm trying to echo user name from socialengine to lightirc but been unable to so it time for me to ask for some help
here my code
Code:
<?php
session_start();
        define('TABLE_PREFIX','engine4_');
	define('DB_USERTABLE','users');
	define('DB_USERTABLE_NAME','displayname');
	define('DB_USERTABLE_USERID','user_id');
	define('DB_USERTABLE_AVATAR','photo_id');
	define('DB_FRIENDSTABLE','user_membership');
	define('DB_FRIENDSTABLE_USERID', 'user_id');
	define('DB_FRIENDSTABLE_FRIENDID', 'resource_id');
	define('DB_FRIENDSTABLE_FRIENDS', 'active');
       function get_user_id()
	{
		global $mysql_db;
		$userid = NULL;
		if (!empty($_COOKIE['PHPSESSID']))
		{
			$result = $db->execute("
				SELECT data
				FROM " . TABLE_PREFIX . "core_session
				WHERE id = '" . $db->escape_string($_COOKIE['PHPSESSID']) . "'
			");

			if ($row = $db->fetch_array($result))
			{
				$data = ($row['data']);
				$data = unserializesession($data);

				if (!empty($data['Zend_Auth']['storage']))
				{
					$userid = $data['Zend_Auth']['storage'];
				}
			}
		}
		return $userid;
	}
function get_username($userid)
	{
		global $db;
		global $language;
		global $show_full_username;
		$users_name = $language[83];
		$result = $db->execute("
			SELECT " . DB_USERTABLE_NAME . " name
			FROM " . TABLE_PREFIX . DB_USERTABLE . "
			WHERE " . DB_USERTABLE_USERID . " = '" . $db->escape_string($userid) . "'
		");
		if ($result AND $db->count_select() > 0)
		{
			$row = $db->fetch_array($result);
			$users_name = $row['name'];
		}
		$pieces = explode(" ", $users_name);
		if ($show_full_username == 1)
		{
			return $users_name;
		}
		else
		{
			return $pieces[0];
		}
	}

		function unserializesession($data)
	{
		if(strlen($data) == 0)
		{
			return array();
		}
		preg_match_all('/(^|;|\})([a-zA-Z0-9_]+)\|/i', $data, $matchesarray, PREG_OFFSET_CAPTURE);
		$returnArray = array();
		$lastOffset = NULL;
		$currentKey = '';
		foreach ($matchesarray[2] as $value)
		{
			$offset = $value[1];
			if (!is_null($lastOffset))
			{
				$valueText = substr($data, $lastOffset, $offset - $lastOffset);
				$returnArray[$currentKey] = unserialize($valueText);
			}
			$currentKey = $value[0];
			$lastOffset = $offset + strlen($currentKey) + 1;
		}
		$valueText = substr($data, $lastOffset);
		$returnArray[$currentKey] = unserialize($valueText);
		return $returnArray;
	}
?>

<?php
$username = $_GET['<?php echo $users_name ?>'];

  if ($username=="") {
	$username = 'Guest_' . rand(100, 100000);
  }

?>
 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
 
<script type="text/javascript">
 var params = {};
params.host                         = "irc.bumblebeechat.net";
params.port                         = "6667";
params.policyPort                   = "843";
params.language                     = "en";
params.charset                      = "utf-8";
params.styleURL                     = "css/lightblue.css";
params.nick                         = "<?php echo $username; ?>";
params.autojoin                     = "<?php echo $roomname; ?>";
params.targetFrame                  = "_blank";
params.contextMenuExternalEvent     = "View My Profile";
params.showServerWindow             = "true";
params.showNickSelection            = "true";
params.perform                      = "/msg NickServ register %pass% <?php echo $email; ?>";
params.showNickPrefixIcons          = "true";
params.soundAlerts                  = "true";
params.showIdentifySelection        = "true";
params.showRegisterNicknameButton   = "true";
params.showRegisterChannelButton    = "false";
params.channelHeader		    = "You Are Chatting In:%channel%     Number Of Users:%users%     Room Mode Is:%mode%"
params.showJoinPartMessages         = "true";
params.showPartChannelButton        = "true";
params.showNewQueriesInBackground   = "false";
params.navigationPosition           = "bottom";
params.showTimestamps               = "false";
params.useUserListIcons             = "true";
params.quitMessage                  = "Sorry to see you go come back soon :D";
params.performContinousWhoRequests  = "fasle";
params.nickPrefix                   = "";
params.nickPostfix                  = "";
params.fontSize                     = "13";
params.autoReconnect                = "true";
params.emoticonPath                 = "emoticons/";
params.emoticonList                 = ":)->Smile.png,;)->Wink.png,:D->Laugh.png,:P->Tease.png,:(->Sad.png,:$->Blush.png,:O->Surprised.png,(H)->Cool.png,:|->Speechless.png,:1o->blink.gif,:'(->Cry.png,:S->unsure.gif,:[->Angry.png,(88)->music.png,(Y)->good.png,(BAD)->bad.png,(BRB)->BRB.png,(A)->Not guilty.png,(OH)->Oh.png,(G)->Gift.png,(6)->Devil.png,^O)->Annoyed.png,(AL)->Alien 1.png,(!AL)->Alien 2.png,(ILL)->Ill.png,(Cam)->PhotoCamera.png,(CRA)->Crazy.png,(FL)->Flower.png,(NOTE)->note.png,(P)->Cellphone.png,(M)->messenger.png,(YAH)->yahoo.png,(*)->star.png,(HH)->hailheavy.png,(S)->sunny.png,(F)->pflower.png,(R)->rainbow.png,(CL)->overcast.png,(BAT)->bat.png,(B)->beer.png,(C)->Teacup.png,(CAR)->car.png,(FF)->french_fries.png,(BUR)->hamburger.png,(CF)->java.png,(PP)->pizza_slice.png,(SD)->soft_drink.png,(FM)->female.png,(MALE)->male.png,(D)->wine.png,(BALL)->ball.png,(BROKEH)->broken_heart.png,(ICES)->iceskate.png,(LY)->love_you.png,(STAKE)->skateboard.png,(SOC)->soccer_ball.png,(TEN)->tennis_ball.png,(TROP)->trophy_gold.png,(MONEY)->wallet.png,(K)->kiss.png,(8)->the_music_icon.png,(GIRL)->girl.png,(BOY)->boy.png";




/* Use this method to send a command to lightIRC with JavaScript */
function sendCommand(command) {
  swfobject.getObjectById('lightIRC').sendCommand(command);
}

/* Use this method to send a message to the active chatwindow */
function sendMessageToActiveWindow(message) {
  swfobject.getObjectById('lightIRC').sendMessageToActiveWindow(message);
}

/* Use this method to set a random text input content in the active window */
function setTextInputContent(content) {
  swfobject.getObjectById('lightIRC').setTextInputContent(content);
}

/* This method gets called if you click on a nick in the chat area */
function onChatAreaClick(nick, ident, realname, channel, host) {
  //alert("onChatAreaClick: "+nick);
}

/* This method gets called if you use the parameter contextMenuExternalEvent */
function onContextMenuSelect(type, nick, ident, realname, channel, host) {
  alert("onContextMenuSelect: "+nick+" for type "+type);
}

/* This method gets called if you use the parameter loopServerCommands */
function onServerCommand(command) {
  return command;
}

/* This method gets called if you use the parameter loopClientCommands */
function onClientCommand(command) {
  return command;
}

/* This event ensures that lightIRC sends the default quit message when the user closes the browser window */
window.onbeforeunload = function() {
  swfobject.getObjectById('lightIRC').sendQuit();
}

/* This loop escapes % signs in parameters. You should not change it */
for(var key in params) {
  params[key] = params[key].toString().replace(/%/g, "%25");
}

/* This method gets called if you use the parameter contextMenuExternalEvent */
function onContextMenuSelect(type, nick, ident, realname) {
  window.open ("profile/"+nick);
}
</script>

<body>
 <div id="lightIRC" style="height:100%; text-align:center;">
  <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
 </div>
 <script type="text/javascript">
    swfobject.embedSWF("lightIRC.swf", "lightIRC", "930", "550", "10.0.0", "expressInstall.swf", params);	
 </script>
</body>
Many Thanks for replies
Whatnot