vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   putting the first attachment in a variable (https://vborg.vbsupport.ru/showthread.php?t=138891)

Sean S 02-09-2007 05:59 AM

putting the first attachment in a variable
 
Hi there,

I'm trying to store the first attachment of the first post in a variable, but no matter what I do, I either get errors, or the showthread page stops loading.

basically this is the code that I have, but it doesn't work. I'm not really sure how I would store the first attachment of the firstpost in a variable,

PHP Code:

global $vbulletin$db;

# First Attachment of the First Post
    
$firstattach $db->query_read("
        SELECT a.attachmentid, a.dateline, a.postid, t.firstpostid
        FROM " 
TABLE_PREFIX "attachment a
        LEFT JOIN " 
TABLE_PREFIX "thread t ON t.firstpostid = a.postid
        ORDER BY a.attachmentid DESC
        LIMIT 1
        "
);
        
        while(
$row $db->fetch_array($firstattach))
        {
        
        
$attachdateline$row['dateline'];
        
$attachid$row['attachmentid'];

        eval(
'$tested .= "' fetch_template('tested') . '";');
        } 

Any sort of help would be appreciated,

thank you.

Analogpoint 02-09-2007 04:11 PM

What are the errors you get? What are you trying to do with this?

Sean S 02-09-2007 04:24 PM

Quote:

Originally Posted by Analogpoint (Post 1178491)
What are the errors you get? What are you trying to do with this?

well the first couple of times, I got errors like "call to an undefined member function query_read" or errors mainly similar to that, but those errors went away after I set the globals.

Then I got no more errors, but the showthread page didn't load. All the other pages load up fine except showthread.

Basically what I'm trying to do is to have the first attachment of the first post stored in a variable so that I can call it within the template on the first post.

hope that makes sense, thanks.

Analogpoint 02-09-2007 04:27 PM

Thanks, maybe I'm still not understanding... I need a coffee.. anyone want to do a starbucks run?

You mean like if the attachement is an image, you want to display it or something? Or if the attachement is a zip file you want the actual binary data of the zipfile in the variable?


All times are GMT. The time now is 08:10 AM.

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.01155 seconds
  • Memory Usage 1,723KB
  • 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
  • (4)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