Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2005, 02:26 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default can't get any data out of a query in a function

these two functions work in conjunction with eachother
PHP Code:
function grps_getgroupinfo($groupid)
{
    global 
$vbulletin;

    
$groupid intval($groupid);

    
$grps_groupinfo $vbulletin->db->query_first("
        SELECT grps.groupid, grps.title, grps.description, grps.approved, grps.create_date, grps.leaderid, grps.membercount, user.username AS leadername, grps_categories.catid, grps_categories.title AS catname, grps_setting.image_name, grps_setting.private_posts, grps_setting.moderate_members, grps_setting.hidden_group, grps_setting.hide_image, grps_setting.edit_details, grps_setting.leaderonly_threads, grps_grouptext.pagetext AS spew, grps_grouptext.edit_reason, grps_grouptext.edit_dateline, grps_grouptext.edit_username
        FROM grps_setting
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = grps.leaderid)
        LEFT JOIN grps ON (grps.groupid = grps_setting.groupid)
        LEFT JOIN grps_grouptext ON (grps_grouptext.groupid = grps.groupid)
        LEFT JOIN grps_categories ON (grps_categories.catid = grps.catid)
        WHERE grps.groupid = 
$groupid
        GROUP BY grps.groupid
        ORDER BY grps.groupid DESC
    "
);

    return 
$grps_groupinfo;
}

function 
grps_getgroupsettings($raw_groupinfo)
{
    global 
$vbulletin$stylevar;

    require_once(
'./includes/class_bbcode.php');
    
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());

    
$grps_rin rand(1,$vbulletin->options['grpsnumrandimages']); //random image if they've failed to upload an image
    
$raw_groupinfo['catname'] = stripslashes($raw_groupinfo['catname']);
    
$raw_groupinfo['edit_reason'] = stripslashes($raw_groupinfo['edit_reason']);
    
$raw_groupinfo['type'] = ($raw_groupinfo['private_posts']) ? "Group Posts Are Private. " "Group Posts Are Public. ";
    
$raw_groupinfo['type'] .= ($raw_groupinfo['moderate_members']) ? "Members Are Moderated. " "";
    
$raw_groupinfo['type'] .= ($raw_groupinfo['hidden_group']) ? "This Group Is Hidden From Listings. " "";
    
$raw_groupinfo['type'] .= ($raw_groupinfo['leaderonly_threads']) ? "Only The Group Leader Can Make Threads. " "";
    
$raw_groupinfo['create_date'] = vbdate($vbulletin->options['dateformat'],$raw_groupinfo['create_date']);
    
$raw_groupinfo['leaderavatar'] = "<img src=\"" $vbulletin->options['bburl'] . "/" fetch_avatar_url($raw_groupinfo['leaderid']) . "\" alt=\"Group Leader: " $raw_groupinfo['leadername'] . "\" />";
    
$raw_groupinfo['membercount'] = intval($raw_groupinfo['membercount']);
    
$gettotalposts $vbulletin->db->query_read("SELECT COUNT(postid) AS totalposts FROM grps_post WHERE threadid != '' AND groupid = " $raw_groupinfo[groupid]); // <--- this info
    
$raw_groupinfo['postcount'] = intval($gettotalposts['totalposts']);
    
$raw_groupinfo[spew] = $parsed_text $parser->do_parse($raw_groupinfo[spew]);
    if (!
$raw_groupinfo['hide_image'])
    {
        
$raw_groupinfo['image'] = ($raw_groupinfo['image_name']) ? "" $getgroupimage "" "<img src=\"" $vbulletin->options[bburl] . "/" $stylevar[imgdir_grps] . "/grps_noimage_" $grps_rin ".gif\" alt=\"" $raw_groupinfo[title] . "\" />";
    }
    
$show['leaderoptions'] = ($raw_groupinfo['leaderid'] == $vbulletin->userinfo['userid']) ? TRUE FALSE;
    
$raw_groupinfo['edit_date'] = vbdate($vbulletin->options['dateformat'], $raw_groupinfo['edit_dateline']);
    
$raw_groupinfo['edit_time'] = vbdate($vbulletin->options['timeformat'], $raw_groupinfo['edit_dateline']);

    return 
$raw_groupinfo;

the implementation is
PHP Code:
    $grps_showgroup grps_getgroupinfo($groupid);

    
$grps_pagetitle $grps_showgroup['title'];
    
$grps_showgroup grps_getgroupsettings($grps_showgroup); 
however, everything else works bar managing to get the postcount, any idea why?
Reply With Quote
  #2  
Old 12-05-2005, 02:39 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$gettotalposts $vbulletin->db->query_read("
$raw_groupinfo['postcount'] = intval($gettotalposts['totalposts']); 
Using a mySQL result resource (eg. handle, interger) as an array most likely won't work too well
Reply With Quote
  #3  
Old 12-05-2005, 03:42 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

arghh, thought i posted in this thread. guess not. thanks kirby

gah, the most basic of mistakes, changed it to query_first and works perfectly, thank you

lol, found my original post
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:26 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.04409 seconds
  • Memory Usage 2,211KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete