annatar
01-27-2010, 08:33 PM
Greetings all.
I'm trying my hand at writing a vBulletin mod for the first time. So far things are going fairly well. I've been able to construct a sample product xml which properly creates and removes a new table to the forum database on install/uninstall.
I've created a plugin which uses the attachment_complete hook. I can see that the plugin is being called after an attachment is viewed for but some reason a database error is occurring. When I look at the query as listed in the error report that I am receiving via email it looks proper and I can in fact execute the query in phpmyadmin successfully.
The plugin I am trying to write simply records which user id downloaded which attachment id and from what host.
The plugin code is:
global $vbulletin, $db;
$userId = $vbulletin->userinfo['userid'];
$attachId = $_REQUEST['attachmentid'];
$sessionId = $vbulletin->session->vars['host'];
$db->query_write("
insert into " . TABLE_PREFIX ."attachmentDownloadHistory
(userid, host, attachmentid)
values
($userId, '$sessionId', $attachId)
");
$db->show_errors();
In the email report the error is
Invalid SQL:
insert into testforum_attachmentDownloadHistory
(userid, host, attachmentid)
values
(1, '127.0.0.1', 2);
The error report lists the MySQL Error and Error Number field as both blank.
Any thoughts, suggestions or steps I might have overlooked?
I'm trying my hand at writing a vBulletin mod for the first time. So far things are going fairly well. I've been able to construct a sample product xml which properly creates and removes a new table to the forum database on install/uninstall.
I've created a plugin which uses the attachment_complete hook. I can see that the plugin is being called after an attachment is viewed for but some reason a database error is occurring. When I look at the query as listed in the error report that I am receiving via email it looks proper and I can in fact execute the query in phpmyadmin successfully.
The plugin I am trying to write simply records which user id downloaded which attachment id and from what host.
The plugin code is:
global $vbulletin, $db;
$userId = $vbulletin->userinfo['userid'];
$attachId = $_REQUEST['attachmentid'];
$sessionId = $vbulletin->session->vars['host'];
$db->query_write("
insert into " . TABLE_PREFIX ."attachmentDownloadHistory
(userid, host, attachmentid)
values
($userId, '$sessionId', $attachId)
");
$db->show_errors();
In the email report the error is
Invalid SQL:
insert into testforum_attachmentDownloadHistory
(userid, host, attachmentid)
values
(1, '127.0.0.1', 2);
The error report lists the MySQL Error and Error Number field as both blank.
Any thoughts, suggestions or steps I might have overlooked?