PDA

View Full Version : Adding attachments into external.php


ManagerJosh
04-09-2005, 10:30 AM
I'm trying to list attachments in external.php so we can see what's files are available.

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
I'm trying to list attachments in external.php so we can see what's files are available.

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
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.


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
post.postid = thread.firstpostid should be post.threadid = thread.threadid, shouldn't it?

ManagerJosh
04-10-2005, 01:06 AM
post.postid = thread.firstpostid should be 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:


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:
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
Try this:
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/images/smilies/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.