vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   What is wrong with this? (https://vborg.vbsupport.ru/showthread.php?t=63129)

Scrub 03-29-2004 01:22 PM

What is wrong with this?
 
I've tried several diff ways to get this to work, but no luck with any. :ermm:

PHP Code:

if ($userinfo['usergroupid'] == && && && && 9)
{
    
$show['link'] = false;
}
else
{
    
$show['link'] = true;



assassingod 03-29-2004 01:27 PM

PHP Code:

if (in_array($bbuserinfo['usergroupid'], 1,3,4,8,9)
{
$show['link'] = false;
}
else
{
$show['link'] = true;


That'll do it:)

Scrub 03-29-2004 01:37 PM

Parse error: parse error, unexpected '{' in ***** on line 487

On line 487 is the { below the if in the code you posted. :(

Dean C 03-29-2004 02:08 PM

Steve just forgot a trailing bracket and to actualy have an array ;) :)

Use this it's more efficient:

PHP Code:

if (in_array($bbuserinfo['usergroupid'], array(1,3,4,8,9)))
{
$show['link'] = false;
}
else
{
$show['link'] = true;



filburt1 03-29-2004 02:11 PM

If you are using vB3, always prefer is_member_of() over a check of the usergroupid key. This will, among other things, take additional usergroups into effect (not just the primary usergroup).

assassingod 03-29-2004 02:58 PM

Quote:

Originally Posted by Dean C
Steve just forgot a trailing bracket and to actualy have an array

Whoops:)

Scrub 03-29-2004 03:34 PM

Thanks guys! :D

Filburt1, where would that go? Kind of a newbie in vB3 code :speechless:

Gary King 03-29-2004 07:48 PM

Quote:

Originally Posted by Scrub
Thanks guys! :D

Filburt1, where would that go? Kind of a newbie in vB3 code :speechless:

PHP Code:

if (is_member_of($bbuserinfo13489));
{
    
// etc.



Scrub 03-29-2004 09:26 PM

Thank you! :D

Scrub 03-31-2004 11:41 PM

Instead of making another thread, I'll post in this one. :D. Anyways, I am stuck yet again and on something that I thought would've been easy to do. :x.

Anyways, I am trying to achive something like member.php does, but no luck in making it work. I've scanned countless files trying almsot everything. LOL. But I need to show a username according to the userid, hence like the member.php file. Thanks in advanced. :)

Gary King 03-31-2004 11:50 PM

Quote:

Originally Posted by Scrub
Instead of making another thread, I'll post in this one. :D. Anyways, I am stuck yet again and on something that I thought would've been easy to do. :x.

Anyways, I am trying to achive something like member.php does, but no luck in making it work. I've scanned countless files trying almsot everything. LOL. But I need to show a username according to the userid, hence like the member.php file. Thanks in advanced. :)

$userinfo = fetch_userinfo($userid);

Then $userinfo is an array that has all the user info such as username, $userinfo['username'], etc.

Scrub 03-31-2004 11:53 PM

You are the king! Thanks again! :D

Scrub 04-10-2004 05:10 PM

Hello again! :)

I am currently trying to pull users from a specific usergroup out of the database. How would I go about doing that? This is the query I have. It only pulls one user out of the database. :(

PHP Code:

$user $DB_site->query_first("SELECT username FROM " TABLE_PREFIX " user WHERE usergroupid = 10"); 


Gary King 04-10-2004 05:42 PM

Using the query_first only gets the first result; use query instead, but then you need to use $DB_site->fetch_array($user); in a while statement.

Scrub 04-13-2004 10:34 AM

Hey,
I appreciate all the help, Gary W. But I am comfused on the while statement. I can't seem to figure out how you make one pretty much. I've looked through the PHP Manual, vBulletin Manual, searched several PHP sites and I am still baffled. I understand a little part I belive.
PHP Code:

if ($_REQUEST['do'] == 'this_thing')
        {
                
$users $DB_site->query("
                            SELECT * 
                            FROM " 
TABLE_PREFIX " user AS user
                            WHERE user.usergroupid = 10
                            ORDER BY user.userid DESC
                            "
);

                while (
$user $DB_site->fetch_array($users))
                    {    
                        
$username fetch_musername($user);
                        eval(
'$main_template_bits = "' fetch_template('main_template_bits') . '";');
                    }

            eval(
'print_output("' fetch_template('main_template') . '");');
        } 

Amd I on the right track? LOL. And I'd very much appriciate if you can make a working sample of a while statement that is in KISS format. :p. Again, I'd like to thank you and everyone else for all the help. :)

Gary King 04-13-2004 10:09 PM

Try something like
PHP Code:

if ($_REQUEST['do'] == 'this_thing'

    
$users $DB_site->query(
        SELECT * 
        FROM " 
TABLE_PREFIX " user AS user 
        WHERE user.usergroupid = 10 
        ORDER BY user.userid DESC 
    "
); 
    
    while (
$user $DB_site->fetch_array($users)) 
    {     
        
$username fetch_musername($user); 
        eval(
'$main_template_bits .= "' fetch_template('main_template_bits') . '";'); 
    } 
    
    eval(
'print_output("' fetch_template('main_template') . '");'); 


Then the main_template_bits would contain a <tr> most likely, or <br /> at the end.

Scrub 04-13-2004 10:31 PM

Thanks man! Though I still don't see where I went wrong at though. Could've it have actually been the template where I forgot the <br /> tag? :confused:

Edit: The <br /> kind of messed up the layout. So I removed it and it still works. :).

Edit again: NEvermind. I missed a . in the eval part in the while query! :D

But thank you so much! :)


All times are GMT. The time now is 06:53 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.01161 seconds
  • Memory Usage 1,778KB
  • 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
  • (7)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (17)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete