I have added the file image upload code while I wait on a response regarding file image upload to database.
Anyway, here is the code I'm using thus far:
PHP Code:
if($_REQUEST['do'] == 'saved')
{
$upload = new vB_Upload_Image($vbulletin);
$upload->image =& vB_Image::fetch_library($vbulletin);
$upload->path = './'.$options['sponsor_imgpath'];
// if (!($upload->process_upload($vbulletin->GPC['img_file']))){
// eval(standard_error(fetch_error('there_were_errors_encountered_with_your_upload_x', $upload->fetch_error())));
// }
$sql = "INSERT INTO `" . TABLE_PREFIX . "sponsors`
(`title` , `url` , `image` , `description`, `inactive`, `img_file`)
VALUES (
'" . $db->escape_string($vbulletin->GPC['title']) . "',
'" . $db->escape_string($vbulletin->GPC['url']) . "',
'" . $db->escape_string($vbulletin->GPC['image']) . "',
'" . $db->escape_string($vbulletin->GPC['description']) . "',
'" . $db->escape_string($vbulletin->GPC['inactive']) . "',
'" . $upload->process_upload($vbulletin->GPC['img_file'] . "'
)");
$vbulletin->db->query_write($sql);
print_cp_message('Sponsor Added.', 'sponsors.php', 5);
}
EDIT: Fixed previous error, new problem.
When I click submit, I get the following error:
Code:
Database error in vBulletin 3.6.8:
Invalid SQL:
INSERT INTO `sponsors`
(`title` , `url` , `image` , `description`, `inactive`, `img_file`)
VALUES (
'Download Now',
'www.download.com',
'',
'blah blah blah again',
'0',
';
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 9
Error Number : 1064
Thanks in advance
Steve