PDA

View Full Version : avatar on a non vb page


jeramie78
07-22-2007, 06:34 AM
hey all,

ok consider me a noob but this is my code to try to get a avatar to display on a non vb page but nothing i seem to do works. some help would realy be appreciated. i get no errors but i dont get any data output either.

<?
$userid = "1";
function fetch_avatar_url($userid)
{
global $vbulletin;

if ($avatarinfo = mysql_queary("
SELECT user.avatarid, user.avatarrevision, avatarpath, NOT ISNULL(customavatar.userid) AS hascustom, customavatar.dateline,
customavatar.width, customavatar.height
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON avatar.avatarid = user.avatarid
LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON customavatar.userid = user.userid
WHERE user.userid = $userid"))
{
if (!empty($avatarinfo['avatarpath']))
{
return array($avatarinfo['avatarpath']);
}
else if ($avatarinfo['hascustom'])
{
$avatarurl = array('hascustom' => 1);

if ($vbulletin->options['usefileavatar'])
{
$avatarurl[] = $vbulletin->options['avatarurl'] . "/avatar{$userid}_{$avatarinfo['avatarrevision']}.gif";
}
else
{
$avatarurl[] = "image.php?u=$userid&amp;dateline=$avatarinfo[dateline]";
}

if ($avatarinfo['width'] AND $avatarinfo['height'])
{
$avatarurl[] = " width=\"$avatarinfo[width]\" height=\"$avatarinfo[height]\" ";
}
return $avatarurl;
}
else
{
return '';

}
}
}
?>

<table>
<td><img src="./images/<? echo "$avatarinfo"; ?>"></td></table>

nexialys
07-22-2007, 01:49 PM
mysql_queary >> mysql_query

from the html snippet, you added ./images/ in it, but the vbulletin avatarurl usually contain it...

what is the output of your code?

jeramie78
07-22-2007, 06:30 PM
Thanks for pointing out the typo ....i however did manage to get it working but only for VB avatars if someone has a custom one it will not work :( So if you can think of a way to get custom urls too i would greatly appreciate it.

<?
$avatarinfo = mysql_query("
SELECT user.avatarid, user.avatarrevision, avatarpath, NOT ISNULL(customavatar.userid) AS hascustom, customavatar.dateline,
customavatar.width, customavatar.height
FROM vb_user AS user
LEFT JOIN vb_avatar AS avatar ON avatar.avatarid = user.avatarid
LEFT JOIN vb_customavatar AS customavatar ON customavatar.userid = user.userid
WHERE user.userid = $userid");

$query_row=mysql_fetch_array($avatarinfo);

echo "<img src=\"forums/$query_row[avatarpath]\">";
?>