thesatman
05-24-2006, 07:21 PM
I'm going crazy trying to get a database query working-
I currently have the following in Hook Location : newpost_process working fine-
// Attachments credits
$attachs = $vbulletin->db->query_read("
SELECT dateline, thumbnail_dateline, filename, filesize, visible, attachmentid, counter,
IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize,
attachmenttype.thumbnail AS build_thumbnail, attachmenttype.newwindow
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype USING (extension)
WHERE posthash = '" . $post['posthash'] . "'
AND userid = " . $vbulletin->userinfo['userid'] . "
ORDER BY attachmentid
");
$attachcount11 = $vbulletin->db->num_rows($attachs);
$credits = $attachcount11 * 20 + 1;
-------------------------------
I now want to add the following WHERE-
AND extension = mid
So it only collects data in mid format but i just keep getting a database error all the time after adding that 1 line ??? Can anybody see a reason why ?
This is what i have when i get the database error-
// Attachments credits
$attachs = $vbulletin->db->query_read("
SELECT dateline, thumbnail_dateline, filename, filesize, visible, attachmentid, counter,
IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize,
attachmenttype.thumbnail AS build_thumbnail, attachmenttype.newwindow
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype USING (extension)
WHERE posthash = '" . $post['posthash'] . "'
AND userid = " . $vbulletin->userinfo['userid'] . "
AND extension = mid
ORDER BY attachmentid
");
$attachcount11 = $vbulletin->db->num_rows($attachs);
$credits = $attachcount11 * 20 + 1;
--------------------------------
Any help appreciated.
I currently have the following in Hook Location : newpost_process working fine-
// Attachments credits
$attachs = $vbulletin->db->query_read("
SELECT dateline, thumbnail_dateline, filename, filesize, visible, attachmentid, counter,
IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize,
attachmenttype.thumbnail AS build_thumbnail, attachmenttype.newwindow
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype USING (extension)
WHERE posthash = '" . $post['posthash'] . "'
AND userid = " . $vbulletin->userinfo['userid'] . "
ORDER BY attachmentid
");
$attachcount11 = $vbulletin->db->num_rows($attachs);
$credits = $attachcount11 * 20 + 1;
-------------------------------
I now want to add the following WHERE-
AND extension = mid
So it only collects data in mid format but i just keep getting a database error all the time after adding that 1 line ??? Can anybody see a reason why ?
This is what i have when i get the database error-
// Attachments credits
$attachs = $vbulletin->db->query_read("
SELECT dateline, thumbnail_dateline, filename, filesize, visible, attachmentid, counter,
IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize,
attachmenttype.thumbnail AS build_thumbnail, attachmenttype.newwindow
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype USING (extension)
WHERE posthash = '" . $post['posthash'] . "'
AND userid = " . $vbulletin->userinfo['userid'] . "
AND extension = mid
ORDER BY attachmentid
");
$attachcount11 = $vbulletin->db->num_rows($attachs);
$credits = $attachcount11 * 20 + 1;
--------------------------------
Any help appreciated.