Cooper
Active member
Hi
Having a few issues using Datawriter - getting 500 error when trying to do the below, creating a new thread:
First PHP Page (included in 2nd)
I know this code block works fine as I use it in other scripts. (domain name removed as is for a new project)
On another page (with the above included) I have:
I just get a 500 error, any thoughts on where I'm going wrong?
TIA
Having a few issues using Datawriter - getting 500 error when trying to do the below, creating a new thread:
First PHP Page (included in 2nd)
PHP:
$startTime = microtime(true);
$fileDir = '/var/www/vhosts/domain.com/httpdocs/forum';
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
XenForo_Session::startPublicSession();
$visitor = XenForo_Visitor::getInstance();
$userid = $visitor->getUserId();
$username = $visitor->get('username');
I know this code block works fine as I use it in other scripts. (domain name removed as is for a new project)
On another page (with the above included) I have:
PHP:
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$writer->set('user_id', $userid);
$writer->set('username', $username);
$writer->set('title', $title);
$postWriter = $writer->getFirstMessageDw();
$postWriter->set('message', $intro);
$writer->set('node_id', $nodeid);
$writer->preSave();
$writer->save();
$thread = $writer->getMergedData();
return $this->responseRedirect(
XenForo_ControllerResponse_Redirect::SUCCESS,
$this->getDynamicRedirect(),
new XenForo_Phrase('your_message_has_been_sent')
);
I just get a 500 error, any thoughts on where I'm going wrong?
TIA