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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-09-2005, 10:30 AM
ManagerJosh's Avatar
ManagerJosh ManagerJosh is offline
 
Join Date: Feb 2002
Posts: 348
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding attachments into external.php

I'm trying to list attachments in external.php so we can see what's files are available.

PHP Code:
if ($_REQUEST['type'] == 'RSS2')
// check for attachments
$attachments $DB_site->query("
SELECT attachment.filename, attachment.filesize, attachment.visible, attachment.attachmentid, attachment.counter, post.postid
FROM " 
TABLE_PREFIX "attachment
WHERE post.postid = 
$postid
ORDER BY attachment.dateline
"
);
while (
$attachment $DB_site->fetch_array($attachments))
{
$post['attachments']["$attachment[attachmentid]"] = $attachment;
}

That code gives me a database error,


Invalid SQL: SELECT attachment.filename, attachment.filesize, attachment.visible, attachment.attachmentid, attachment.counter, post.postid FROM attachment WHERE post.postid = ORDER BY attachment.dateline mysql error: You have an error in your SQL syntax near 'ORDER BY attachment.dateline ' at line 5mysql error number: 1064


So yea, didn't work...ideas?
Reply With Quote
  #2  
Old 04-09-2005, 10:39 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ManagerJosh
I'm trying to list attachments in external.php so we can see what's files are available.

PHP Code:
if ($_REQUEST['type'] == 'RSS2')
// check for attachments
$attachments $DB_site->query("
SELECT attachment.filename, attachment.filesize, attachment.visible, attachment.attachmentid, attachment.counter, post.postid
FROM " 
TABLE_PREFIX "attachment
WHERE post.postid = 
$postid
ORDER BY attachment.dateline
"
);
while (
$attachment $DB_site->fetch_array($attachments))
{
$post['attachments']["$attachment[attachmentid]"] = $attachment;
}

That code gives me a database error,


Invalid SQL: SELECT attachment.filename, attachment.filesize, attachment.visible, attachment.attachmentid, attachment.counter, post.postid FROM attachment WHERE post.postid = ORDER BY attachment.dateline mysql error: You have an error in your SQL syntax near 'ORDER BY attachment.dateline ' at line 5mysql error number: 1064


So yea, didn't work...ideas?
Don't you need a join of some sort to get the post.postid from the POST TABLE

Not to mention a table prefix for it.
Reply With Quote
  #3  
Old 04-09-2005, 10:59 AM
ManagerJosh's Avatar
ManagerJosh ManagerJosh is offline
 
Join Date: Feb 2002
Posts: 348
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery
Don't you need a join of some sort to get the post.postid from the POST TABLE

Not to mention a table prefix for it.
I have no idea really Zach

My Objective is merely to get an attachment url link to appear in rss feeds



Edit: Tested code, doesn't work.


PHP Code:
if ($_REQUEST['type'] == 'MEDIA')
// check for attachments
 
$attachments $DB_site->query("
  SELECT attachment.filename, attachment.filesize, attachment.attachmentid, attachment.postid
  FROM " 
TABLE_PREFIX "attachment
  LEFT JOIN " 
TABLE_PREFIX "post ON (post.postid = attachment.postid)
  LEFT JOIN " 
TABLE_PREFIX "thread ON (post.postid = thread.firstpostid)
  ORDER BY thread.dateline DESC
  LIMIT 15
 "
);
 while (
$attachment $DB_site->fetch_array($attachments))
 {
  
$post['attachments']["$attachment[attachmentid]"] = $attachment;
 }

Reply With Quote
  #4  
Old 04-10-2005, 12:25 AM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
post.postid = thread.firstpostid
should be
Code:
post.threadid = thread.threadid
, shouldn't it?
Reply With Quote
  #5  
Old 04-10-2005, 01:06 AM
ManagerJosh's Avatar
ManagerJosh ManagerJosh is offline
 
Join Date: Feb 2002
Posts: 348
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Link14716
Code:
post.postid = thread.firstpostid
should be
Code:
post.threadid = thread.threadid
, shouldn't it?
Hmm...that improves the performance of the script, but it doesn't answer why the attachment data isn't being sent out.

Data is being used in this form:

PHP Code:
if ($_REQUEST['type'] == 'MEDIA')
    {    
      echo 
"\t\t<enclosure url=\"" 
htmlspecialchars("$vboptions[bburl]/attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&filename=$attachment[filename]") . "\" length=\"$attachment[filesize]\" type=\"audio/mpeg\" />\r\n";
    } 
Reply With Quote
  #6  
Old 04-10-2005, 04:08 AM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this:
PHP Code:
if ($_REQUEST['type'] == 'MEDIA')
// check for attachments
    
$attachments $DB_site->query("
      SELECT attachment.filename, attachment.filesize, attachment.attachmentid, attachment.postid
      FROM " 
TABLE_PREFIX "attachment
      LEFT JOIN " 
TABLE_PREFIX "post ON (post.postid = attachment.postid)
      LEFT JOIN " 
TABLE_PREFIX "thread ON (post.threadid = thread.threadid)
      WHERE post.postid = thread.firstpostid
      ORDER BY thread.dateline DESC
      LIMIT 15
    "
);
    while (
$attachment $DB_site->fetch_array($attachments))
    {
        echo 
"\t\t<enclosure url=\"" .htmlspecialchars("$vboptions[bburl]/attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&filename=$attachment[filename]") . "\" length=\"$attachment[filesize]\" type=\"audio/mpeg\" />\r\n";
    }

After spending an hour over IRC, we finally got it to work correctly.

Link for mod!
Reply With Quote
  #7  
Old 05-11-2005, 02:55 PM
Nordinho Nordinho is offline
 
Join Date: Aug 2004
Location: Netherlands
Posts: 288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Link14716
Try this:
PHP Code:
if ($_REQUEST['type'] == 'MEDIA')
// check for attachments
    
$attachments $DB_site->query("
      SELECT attachment.filename, attachment.filesize, attachment.attachmentid, attachment.postid
      FROM " 
TABLE_PREFIX "attachment
      LEFT JOIN " 
TABLE_PREFIX "post ON (post.postid = attachment.postid)
      LEFT JOIN " 
TABLE_PREFIX "thread ON (post.threadid = thread.threadid)
      WHERE post.postid = thread.firstpostid
      ORDER BY thread.dateline DESC
      LIMIT 15
    "
);
    while (
$attachment $DB_site->fetch_array($attachments))
    {
        echo 
"\t\t<enclosure url=\"" .htmlspecialchars("$vboptions[bburl]/attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&filename=$attachment[filename]") . "\" length=\"$attachment[filesize]\" type=\"audio/mpeg\" />\r\n";
    }

After spending an hour over IRC, we finally got it to work correctly.

Link for mod!
hmmm...wondering...so the code above works and adds attachment to rssfeeds??
Reply With Quote
  #8  
Old 05-16-2006, 07:48 AM
pokerie pokerie is offline
 
Join Date: Apr 2006
Posts: 124
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know this post is LONG dead, but this is what I want to do. I've pasted the code into fps_external.php and tried with the normal external.php and it works in neither for me. What else can I do to get it working? I'm parsing the feed with simplepie but it isn't showing anything for the enclosure bit.
Reply With Quote
  #9  
Old 07-03-2006, 11:50 PM
nhatrang nhatrang is offline
 
Join Date: Jun 2004
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am also trying to get this working and it doesn't seem to work either... anybody got any other solution? Please help.
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 02:21 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09555 seconds
  • Memory Usage 2,293KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_code
  • (6)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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