Ok,I think Im using your code wrong too ...
$query = "SELECT * FROM online WHERE timeout > \"$timeout\""; #Check and see who is online in the last 2 minutes
$online = mysql_query($query); #Execute query
$row_online = mysql_fetch_assoc($online); #Grab the users
/*
$users_online = $row_online['username'];
if (isset($row_online['username'])) { #If there is atleast one user online
do {
implode(", ", $users_online);
} while($row_online = mysql_fetch_assoc($online)); #Until all records are displayed
} else {
echo "There are no members online."; #Inform user that no one is online
}
*/
if (isset($row_online['username'])) {
do{
$i = 0;
while( $row = mysql_fetch_assoc($online) )
{
echo ($i == 0) ? $row['username'] : ', ' . $row['username'];
/* Ternary operator, in affect its the same as this:
# if( $i == 0 )
# {
# echo $row['username'];
# }
# else
# {
# echo ', ' . $row['username'];
# }
*/
$i++;
}
}
else {
echo "There are no members online."; #Inform user that no one is online
}
}
This is how I implemented it and this is error I get
Quote
Parse error: syntax error, unexpected T_ELSE, expecting T_WHILE in /home/***/public_html/upload/index.php on line 251
Line 251 is line with
else
Edited by Friiks, 26 November 2006 - 05:24 PM.