News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to get the avatar of a user from an external script?

Started by Remaker, June 12, 2006, 12:24:10 PM

Previous topic - Next topic

Remaker

I'm trying to get the avatar of an user from an external script.
Everything it's working except when the user has uploaded an avatar... how to get the url to the avatar? where is it stored in the database? thanks.

this is what I managed to do until now:

$h=mysql_query("SELECT * FROM smf_members WHERE avatar<>'' ORDER BY RAND() LIMIT 5;");
while ($user = mysql_fetch_assoc($h)) {
if (strpos($user['avatar'],'http://')){
echo '<li><a href="#"><img src="'.$user['avatar'].'" width="105" height="105" alt="'.$user['memberName'].' \'s profile image" /></a>  <h2>'.$user['memberName'].'</h2></li>';
} else
{
echo '<li><a href="#"><img src="forum/avatars/'.$user['avatar'].'" width="105" height="105" alt="'.$user['memberName'].' \'s profile image" /></a> <h2>'.$user['memberName'].'</h2></li>';
}
}


when the user has an uploaded avatar,  the "avatar" field is empty in the mysql database...

I need a solution for SMF 1.0.7
Remaker - My blog - Actualitate.net

Remaker

For anyone interesed. I found how to do it.

It seems that avatars are stored in smf_attachements tables attached to no message( dhaa :) ), and to the member we want. so a simple query should give us the url.


$qq=mysql_query("SELECT ID_ATTACH FROM smf_attachments WHERE (ID_MSG=0 AND ID_MEMBER=".$user['ID_MEMBER'].")");
$avatar=mysql_fetch_array($qq);
echo '<img src="http://localhost/forum/index.php?action=dlattach;id='.$avatar[0].';type=avatar"/>';
Remaker - My blog - Actualitate.net

Advertisement: