2015-10-03, 04:49 AM
Hello, I run a myBB forum. http://orcahub.com/forum/
I also do a lot of work in PHP.
I want to make a new thread in a specified category from my admin account on the forum, with specific title and contents from my php script.
Here is what I used to use, but this will generate problems over time as it isn't completely right
Here is the method I coded myself
What is the official way to do it?
I also do a lot of work in PHP.
I want to make a new thread in a specified category from my admin account on the forum, with specific title and contents from my php script.
Here is what I used to use, but this will generate problems over time as it isn't completely right
Here is the method I coded myself
function makethread($subject, $thread) {
$host="***"; // Host name
$username="***"; // Mysql username
$password="***"; // Mysql password
$db_name="***"; // Database name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$ridtid = rand(111111,999999);
$time = time();
$q1 = "INSERT into mybb_posts (tid, fid, subject, icon, uid, username, message, visible) VALUES('$ridtid', '7', '$subject', '6', '1', 'Nick', '$thread', '1')";
$q2 = "INSERT into mybb_threads (tid, fid, subject, icon, uid, username, dateline, lastpost, lastposter, visible) VALUES('$ridtid', '7', '$subject', '6', '1', 'Nick', '$time', '$time', 'Nick', '1')";
$q3 = "UPDATE mybb_forums SET lastposttid='$ridtid' WHERE fid='7'";
$q4 = "UPDATE mybb_forums SET lastpost='$time' WHERE fid='7'";
mysql_query($q1);
mysql_query($q2);
mysql_query($q3);
mysql_query($q4);
}
What is the official way to do it?