vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Adding attachments into external.php (https://vborg.vbsupport.ru/showthread.php?t=79663)

ManagerJosh 04-09-2005 10:30 AM

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?

Zachery 04-09-2005 10:39 AM

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 :p

Not to mention a table prefix for it.

ManagerJosh 04-09-2005 10:59 AM

Quote:

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

Not to mention a table prefix for it.

I have no idea really Zach :p

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;
 }



Link14716 04-10-2005 12:25 AM

Code:

post.postid = thread.firstpostid
should be
Code:

post.threadid = thread.threadid
, shouldn't it?

ManagerJosh 04-10-2005 01:06 AM

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";
    } 


Link14716 04-10-2005 04:08 AM

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! https://vborg.vbsupport.ru/

Nordinho 05-11-2005 02:55 PM

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! http://forums.gamewinners.com/forums...ilies/link.gif

hmmm...wondering...so the code above works and adds attachment to rssfeeds??

pokerie 05-16-2006 07:48 AM

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.

nhatrang 07-03-2006 11:50 PM

I am also trying to get this working and it doesn't seem to work either... anybody got any other solution? Please help.


All times are GMT. The time now is 01:28 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.01057 seconds
  • Memory Usage 1,783KB
  • 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
  • (4)bbcode_code_printable
  • (6)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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