I am wondering my class property $friend_username does not returning its value either it is public.
update
class Feed { public static $friend_username; // ONLINE FRIENDS LOGIC public function online_friends(){ $friendsHTML = ''; $countOnlineFriends = ''; if(GetFriends($GLOBALS['log_username']) != false) { $all_friends = GetFriends($GLOBALS['log_username']); $orLogic = ''; foreach($all_friends as $key => $user){ if(IsBlocked($GLOBALS['log_username'],$user,true) == false){ $orLogic .= "username='$user' OR "; } } $orLogic = chop($orLogic, "OR "); $sql = "SELECT username, avatar, logged_in FROM users WHERE ($orLogic) AND logged_in = 1"; $query = mysqli_query($GLOBALS['db_conx'], $sql); $friend_loggedIn = array(); while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $this->friend_username = $row["username"]; $friend_avatar = $row["avatar"]; $friend_loggedIn[] = $row["logged_in"]; $friend_pic = userImage($this->friend_username,$friend_avatar,'42','42',$link = false,$up = true); $friendsHTML .= '<li><a href="#" onClick="chatbox(\''.$this->friend_username.'\',\''.getName($this->friend_username,true).'\');return false;">'.$friend_pic.' '.getName($this->friend_username,true).'</li>'; $countFriends = count($friend_loggedIn); $countOnlineFriends = ($countFriends > 0) ? '<span class="online_friends animated">'.$countFriends.'</span>' : ''; } }else{ $friendsHTML = 'No friends'; } return "$countOnlineFriends|$friendsHTML"; } public function update_chat() { $id = ''; $messages = ''; $randUser = ''; $user = sanitize($this->friend_username); $sql = "SELECT * FROM pm_chat WHERE (sender='$GLOBALS[log_username]' AND receiver='$user') OR (sender='$user' AND receiver='$GLOBALS[log_username]') ORDER BY datetime DESC"; $result = mysqli_query($GLOBALS['db_conx'],$sql) or die(mysqli_error($GLOBALS['db_conx'])); while ($row = mysqli_fetch_assoc($result)) { $id = $row['id']; $user1 = $row['sender']; $user2 = $row['receiver']; $message = parseData($row['message']); $did_read = $row['did_read']; $datetime = $row['datetime']; if ($user1 != $GLOBALS['log_username']) { $randUser = $user1; }elseif ($user2 != $GLOBALS['log_username']) { $randUser = $user2; } if ($user1 == $GLOBALS['log_username'] && $user2 != $GLOBALS['log_username']) { $messages .= '<li class="row" id="pm_row_'.$id.'"><div class="me">'.$message.'</div></li>'; }else{ $messages .= '<li class="row" id="pm_row_'.$id.'">'.userImage($randUser,getAvatar($randUser),28,28,$link = true,$up = true).'<div class="userfrnd">'.$message.'</div></li>'; } } return $this->friend_username."$id|$messages|$randUser"; // this is for ^^^^^^^ testing purpose } } here is the other file where I am calling the other class method. And its content-type is text/event-stream
class update_chat extends SSEEvent { public function update(){ //Here's the place to send data $feed = new Feed(); return $feed->update_chat(); } public function check(){ //Here's the place to check when the data needs update return true; } } Any idea or suggestion why this problem persist ?
thanks in advance.
$row["username"]is empty?$row["username"]is not empty, I am also using that and its working good.foo()method is returning its all values where I am using it. but its not returning its value inbar()since I callbar()in another file.