vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Why doesn't this code to display avatars work? (https://vborg.vbsupport.ru/showthread.php?t=211219)

tomotron 04-14-2009 08:11 PM

Why doesn't this code to display avatars work?
 
I'm trying to display avatars (hosted in the filesystem) on a non-vb page. Basically, I'm supplying a userid and want to display the avatar...

PHP Code:


$avatarid 
1;

require_once(
'./includes/functions_user.php');

$avatarurl fetch_avatar_url($avatarid);
        if (
$avatarurl[0])
        {
            
$avatarurl $avatarurl[0];
        }
        else 
        {
            
$avatarurl "noavatar.gif";
    } 

$avatarurl never contains any data :(

From all the examples I've read it seems like this *should* work, am I making a stupid mistake? Any help is appreciated!

--------------- Added [DATE]1239745335[/DATE] at [TIME]1239745335[/TIME] ---------------

also, just to be clear this file resides in my vbulletin directory so the path to functions_user.php should be good.

tomotron 04-19-2009 05:17 PM

anybody? is there another solution to display avatars that are NOT hosted in the database on a non vb page?

Lynne 04-19-2009 05:19 PM

Exactly what is getting displayed in the source code? And maybe it would be better to go:
PHP Code:

       if (!empty($avatarurl)) 
        { 
            
$avatarurl $avatarurl
        } 
        else  
        { 
            
$avatarurl "noavatar.gif"
    } 


tomotron 04-20-2009 05:39 PM

^^ I think we're basically doing the same thing there?

When i try to run this and print the results using "echo $avatarurl;" for example I get nothing. It doesn't display noavatar.gif which should display if $avatarurl is empty.

I can replace,

$avatarurl = fetch_avatar_url($avatarid);
with
$avatarurl = 1;

and the script runs and I can display the results (which are 1), so my issue lies with the fetch_avatar_url($avatarid); portion which doesn't seem to be pulling the info it's supposed to.
Do I need to include other files to access that function?

Lynne 04-20-2009 07:07 PM

Did you look at the API for that function? I believe it returns an array. Is $avatarurl defined as an array? According to the API, that is the correct file to include.

tomotron 04-23-2009 12:52 PM

Yeah looking at the API is where I got most of this code.

The if statement should deal with the array,

basically saying if there is a value for $avatarurl[0] assign it to $avatarurl, otherwise gave $avatarurl the value "noavatar.gif"

EnIgMa1234 04-23-2009 01:07 PM

Try a
Code:

print_r($avatarurl);

tomotron 04-24-2009 10:02 PM

^^ Tried it, I think $avatarurl = fetch_avatar_url($avatarid); just isn't working :confused:

Lynne 04-24-2009 11:11 PM

Did you try looking in the vb code to find a some code where this function is and then just copying it?

And, if $avatarurl is defined as an array, you can't then just go use it as if it isn't an array.

tomotron 05-04-2009 06:19 PM

Quote:

Originally Posted by Lynne (Post 1798493)
Did you try looking in the vb code to find a some code where this function is and then just copying it?

And, if $avatarurl is defined as an array, you can't then just go use it as if it isn't an array.

I'm not so sure I think the problem is in my code, but more than I'm trying to do this on a non-vb page and there's a step I'm missing to be able to use that function.

$avatarurl is an array, but I am using it as one... $avatarurl[0] would access the first element in the array which should be the URL for the avatar.


All times are GMT. The time now is 01:29 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01031 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete