MyBB Community Forums

Full Version: [Help] Adding a Post Reply Automatically
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to receive some help from you for adding my database's data to the forum.

Actually Iam trying to add a reply to the post. The following code Iam using to add the post. But it results nothing. Can you say what is missing on the following code to make a new reply to a thread?


$query = "SQL QUERY";
$result = mysql_query($query);
	$posthandler = new PostDataHandler("insert");
	$posthandler->action = "do_newreply";
	$post = array(
		"tid" => $tid,
		"fid" => $fid,
		"subject" => $subject,
		"icon" => -1,
		"uid" => 1,
		"username" => 'admin',
		"message" => $message,
		"ipaddress" => '',
		"posthash" => '',
		"savedraft" => 0,
	);



	// Set up the post options from the input.
	$post['options'] = array(
		"signature" => 'yes',
		"emailnotify" => 'no',
		"disablesmilies" => 'yes'
	);


	$posthandler->set_data($post);

	$valid_post = $posthandler->validate_post();

	// Fetch friendly error messages if this is an invalid post
	if(!$valid_post)
	{
		die("Error on Inserting Post");
	}


What is missing on the code to make it as a successful reply?
Can you post the full script ?
Did you add this ?
require_once MYBB_ROOT."inc/datahandlers/post.php";
Yes. It have require_once MYBB_ROOT."inc/datahandlers/post.php"; on the first line.

The file does not produce any error messages.

But it not making any replys to the board.

I managed to make new thread. But failed to make new replys.

What else is needed to the code to work fine?
this ?
$postinfo = $posthandler->insert_post();
Thanks for the reply.

After adding the line, It is working. Thanks.......