PDA

View Full Version : avatar code error


TECK
03-30-2002, 01:59 PM
i have trouble pulling from the post the avatar:$newssql=$DB_site->query("
SELECT * FROM thread
WHERE forumid='$newsforum'
ORDER BY dateline DESC LIMIT $newsposts
");
while ($news=$DB_site->fetch_array($newssql)) {
$getnewssql=$DB_site->query_first("
SELECT pagetext
".iif($avatarenabled,",avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline","")."
FROM post
".iif ($avatarenabled,"LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON customavatar.userid=user.userid","")."
WHERE threadid='$newsthreadid'
ORDER BY postid ASC LIMIT 1
");
$newstext=bbcodeparse($getnewssql[pagetext]);
$newsavatar=$getnewssql[avatar];
}what do i do wrong?

Admin
03-30-2002, 02:01 PM
You need to add a JOIN to your query, on the user table.

TECK
03-30-2002, 02:06 PM
i pm you the code FireFly..
hehe a love that most of my hacks contain credits for your work.. :)

TECK
03-30-2002, 02:09 PM
LEFT JOIN user ON user.userid=post.userid

?

Admin
03-30-2002, 02:11 PM
Yup. But since you are doing this every time anyway, I suggest using getavatarurl() as it will save you 3 JOINs, one of them is on the user table which is huge.

TECK
03-30-2002, 02:17 PM
can you clear the last part of the mistery for me? that's all i need to release the hack.
i looked in functions.php but i'm a little confused how to call the avatar from it with getavatarurl($userid)
thanks for your time.

Admin
03-30-2002, 02:30 PM
Never mind, use what you had before it's the same. Either way you get the same thing I think.

But basically you just call getavatarurl with a user id and it gives you what you need to use in the <img src="...."> tag.

TECK
03-30-2002, 02:32 PM
i will use the getavatarurl. i think is a more elegant solution.
i will post here the rest of the code so you can evaluate it.
although, can you tell me where is called, from functions.php that bit of code? so i can see the code mechanism?

thanks for your help firefly.

TECK
03-30-2002, 03:06 PM
i got it working. ;)

TECK
03-31-2002, 03:12 AM
i have another problem:$newssql=$DB_site->query("SELECT * FROM thread
WHERE forumid='$newsforum'
ORDER BY dateline DESC LIMIT $newsposts");
while ($news=$DB_site->fetch_array($newssql)) {
$newsthreadid=$news[threadid];
$newstitle=$news[title];
$newstime=vbdate($timeformat,$news[dateline]);
$newsdate=vbdate($dateformat,$news[dateline]);
$newsusername=$news[postusername];
$newsuserid=$news[postuserid];
$getnewssql=$DB_site->query_first("SELECT * FROM post
WHERE threadid='$newsthreadid'
ORDER BY postid ASC LIMIT 1");
$newstext=bbcodeparse($getnewssql[pagetext]);
$newsavatarurl=getnewsavatar($newsuserid);
if ($newsavatarurl=="") {
$newsavatarurl="{imagesfolder}/clear.gif";
}

eval("\$newsavatar .= \"".gettemplate('home_avatar')."\";");
eval("\$newsbits .= \"".gettemplate('home_newsbits')."\";");
}it adds an extra image every time i add a new post, so if i have 3 threads started, i will have 3avatars for a post?? here it is an example:

TECK
03-31-2002, 03:33 AM
lol.. i'm an idiot. i fix it in no time... sorry.

Scott MacVicar
03-31-2002, 08:51 AM
it was the extra period before the equals ;)

TECK
03-31-2002, 09:12 AM
yes PPN.. i didnt see it.. i was sooo tired. :)