vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   PHP if condition (https://vborg.vbsupport.ru/showthread.php?t=230048)

Mythotical 12-12-2009 04:29 PM

PHP if condition
 
Well found another coding error and can't seem to figure out what is going on. Need someone to look over this for me and tell me if there is another way to work the if condition or work around for it.

PHP Code:

$query $db->query_read("SELECT * FROM " TABLE_PREFIX "download WHERE catid = '" $cid ");
    while (
$dl = $db->fetch_array($query))
        {
            
$fid = $dl['file_id'];
            
            
$moderated = $dl['moderated'];
            
$version = $dl['version'];
            
$name = $dl['name'];
            
$title = $dl['title'];
            
$size = $dl['size'];
            
$description = $dl['description'];
            
$username = $dl['username'];
            
$userid = $dl['userid'];
            
$ugpid = $dl['usergroupid'];
            
$bytes = vbmksize($size);
            
$fileview  = $ugpid;

                if (!empty(
$ugpid))
                    {
                        
$ugpids = explode(',', $ugpid);
                    }
                        else
                    {
                        
$ugpids = array('0');
                    }
                        
$myids = '';
                if (
$vbulletin->userinfo['membergroupids'] == '')
                    {
                        
$myids = array($vbulletin->userinfo['usergroupid']);
                    }
                        else
                    {
                        
$myids = explode(',',$vbulletin->userinfo['membergroupids']);
                    }
            
                
$showfile = 0;

            if (!empty(
$ugpid))
            {
                for (
$i=0; $i<=20; $i++)
                    {
                        if (in_array(
$ugpids[$i]$myids))
                            {
                                
$showfile = 1;
                            }
                    }
            }


Thanks in advance for the help
Steve

Lynne 12-12-2009 04:59 PM

What is it that you want to happen and what is happening? Just seeing some code without an explanation doesn't give me a place to start. Is this a plugin? Where does the output go?

Mythotical 12-12-2009 05:46 PM

The variable $showfile is used in my template to display the file depending on the usergroup ids pull from the DB. Instead of it showing any files it is blank. I remove the $showfile if condition and it works so I know the showfile variable is causing the issue, its not rendering the usergroup ids as existent or something.

BBR-APBT 12-12-2009 06:44 PM

Did you register the $showfile variable?

If it is not registered in the template it will display nothing.

Mythotical 12-12-2009 08:00 PM

BBR-APBT: You have a point, I completely forgot about that variable. I will check it.

BBR-APBT 12-12-2009 08:07 PM

Quote:

Originally Posted by Steve M (Post 1929523)
BBR-APBT: You have a point, I completely forgot about that variable. I will check it.

I been there, I was like wtf the template is being called from the debug. But nothing showed.

LOL

It may not be the case but if you have not registered it I would say that is the case.

Mythotical 12-12-2009 08:13 PM

Thanks much, that was the case. Can't believe I missed that variable. It works now, I can finish playing WoW happy and work on it more this evening.


All times are GMT. The time now is 10:24 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.01510 seconds
  • Memory Usage 1,740KB
  • 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_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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