Could we see the rest of the code please just so we can see what $user['uid'] should be?
(2013-06-07, 04:07 PM)Euan T Wrote: [ -> ]Could we see the rest of the code please just so we can see what $user['uid'] should be?
} elseif($mybb->input['action'] == 'awarded') {
$page .= "<tr><td class=\"thead\" colspan=\"3\">Recently Awarded Users</td></tr>
<tr><td class=\"tcat smalltext\" align=\"center\"><strong>Username</strong></td><td class=\"tcat smalltext\" align=\"center\"><strong>Award Icon</strong></td><td class=\"tcat smalltext\" align=\"center\"><strong>Reason</strong></td></tr>";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."myawards_users ORDER BY awutime DESC LIMIT 25");
$user = get_user($user['awuid']);
$username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
while($user = $db->fetch_array($query))
{
$page .= "<tr><td class=\"trow1\" width=\"20%\" align=\"center\">".$username."</td>
<td class=\"trow1\" width=\"20%\" align=\"center\">".$user['awid']."</td>
<td class=\"trow1\" width=\"60%\" align=\"center\">".$user['awreason']."</td></tr>";
}
$page .= "</table><table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\" style=\"width: 20%\">
<tbody><tr><td class=\"thead\">Menu</td></tr>
{$links}
</tbody></table>";
Use you this code inside the while loop;
$user = get_user($user['awuid']);
$username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
$user isn't defined, which will be why it isn't working. Try this:
} elseif($mybb->input['action'] == 'awarded') {
$page .= "<tr><td class=\"thead\" colspan=\"3\">Recently Awarded Users</td></tr>
<tr><td class=\"tcat smalltext\" align=\"center\"><strong>Username</strong></td><td class=\"tcat smalltext\" align=\"center\"><strong>Award Icon</strong></td><td class=\"tcat smalltext\" align=\"center\"><strong>Reason</strong></td></tr>";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."myawards_users ORDER BY awutime DESC LIMIT 25");
if ($db->num_rows($query) > 0) {
while($user = $db->fetch_array($query)) {
$userDetails = get_user((int) $user['awuid']);
$username = format_name($userDetails['username'], $userDetails['usergroup'], $userDetails['displaygroup']);
$page .= "<tr><td class=\"trow1\" width=\"20%\" align=\"center\">".$username."</td>
<td class=\"trow1\" width=\"20%\" align=\"center\">".$user['awid']."</td>
<td class=\"trow1\" width=\"60%\" align=\"center\">".$user['awreason']."</td></tr>";
}
}
$page .= "</table><table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\" style=\"width: 20%\">
<tbody><tr><td class=\"thead\">Menu</td></tr>
{$links}
</tbody></table>";
(2013-06-07, 04:13 PM)Yaldaram Wrote: [ -> ]Use you this code inside the while loop;
$user = get_user($user['awuid']);
$username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
Dayum, worked perfectly. Thanks Yaldaram!
(2013-06-07, 04:14 PM)Euan T Wrote: [ -> ]$user isn't defined, which will be why it isn't working. Try this:
} elseif($mybb->input['action'] == 'awarded') {
$page .= "<tr><td class=\"thead\" colspan=\"3\">Recently Awarded Users</td></tr>
<tr><td class=\"tcat smalltext\" align=\"center\"><strong>Username</strong></td><td class=\"tcat smalltext\" align=\"center\"><strong>Award Icon</strong></td><td class=\"tcat smalltext\" align=\"center\"><strong>Reason</strong></td></tr>";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."myawards_users ORDER BY awutime DESC LIMIT 25");
if ($db->num_rows($query) > 0) {
while($user = $db->fetch_array($query)) {
$userDetails = get_user((int) $user['awuid']);
$username = format_name($userDetails['username'], $userDetails['usergroup'], $userDetails['displaygroup']);
$page .= "<tr><td class=\"trow1\" width=\"20%\" align=\"center\">".$username."</td>
<td class=\"trow1\" width=\"20%\" align=\"center\">".$user['awid']."</td>
<td class=\"trow1\" width=\"60%\" align=\"center\">".$user['awreason']."</td></tr>";
}
}
$page .= "</table><table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\" style=\"width: 20%\">
<tbody><tr><td class=\"thead\">Menu</td></tr>
{$links}
</tbody></table>";
Yours actually worked better. Thanks a lot, Euan.
Also, it's a good idea to use htmlspecialchars_uni() when outputting raw data from the database like that to protect against possible XSS attacks.