The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Insert Thread into database.
Hello all,
im trying to create a PHP Function that will add a thread to the forums. This is what i got must its not working: Code:
private function MakeThread( $ForumId, $Title, $Content ) { mysql_query( "INSERT INTO `thread` (`threadid`,`title`,`prefixid`,`firstpostid`,`lastpostid`,`lastpost`,`forumid`,`pollid`,`open`,`replycount`,`hiddencount`,`deletedcount`,`postusername`,`postuserid`,`lastposter`,`dateline`,`lastedit`,`views`,`iconid`,`notes`,`visible`,`sticky`,`votenum`,`votetotal`,`attach`,`similar`,`taglist`,`vbseo_linkbacks_no`,`lastposterid`,`keywords`,`wrdate`) VALUES (NULL, '". mysql_real_escape_string($Title) ."', '', '0', '0', '". $ForumId ."', '0', '0', '0', '0', '0', '". $this->UserData['username'] ."', '". $this->UserData['userid'] ."', '". $this->UserData['username'] ."', '". SCRIPT_TIME ."', '0', '0', '', '0', '', '1', '0', '0', '0', '0', '0', '0', '". $this->UserData['userid'] ."', '0', '0')" ) or die( "Q1: " . mysql_error( ) ); // Get the inserted thread ID $ThreadID = mysql_insert_id( ); mysql_query( "INSERT INTO 'post` (`postid`,`threadid`,`parentid`,`username`,`userid`,`title`,`dateline`,`lastedit`,`pagetext`,`allowsmilie`,`showsignature`,`ipaddress`,`iconid`,`visible`,`attach`,`infraction`,`reportthreadid`,`htmlstate`) VALUES (NULL, '". $ThreadID ."', '0', '". $this->UserData['username'] ."', '". $this->UserData['userid'] ."', '', '". SCRIPT_TIME ."', '', '" . $Content . "', '0', '0', '". $this->UserIP ."', '0', '1', '0', '0', '0', 'on_nl2br')" ) or die( "Q2: " . mysql_error( ) ); $PostID = mysql_insert_id( ); mysql_query( "UPDATE `thread` SET `firstpostid` = " . $PostID . ", `lastpostid` = " . $PostID . " WHERE `threadid` = " . $ThreadID . " LIMIT 1" ); } At this point no thread is being made. Thanks |
#2
|
|||
|
|||
I'm not sure, but if I'm counting right it looks like maybe you're not setting 'visible' to 1 (it looks like you're setting 'sticky' to 1 so probably something's off by one).
|
#3
|
|||
|
|||
Quote:
I counted and it looks correct. |
#4
|
|||
|
|||
I count 31 columns and 30 values, again unless I'm screwing up somehow. I pasted it into phpmyadmin, changed the vars to constants, and I got a "value count doesn't match" or something like that (the first query, I mean).
But I don't know why you wouldn't see any error messages. Here's a stupid question - are you sure that's even getting called? |
#5
|
|||
|
|||
Quote:
i just did a re-count and got 31 columns and 31 values. Im stumped on this. |
#6
|
||||
|
||||
Check out my "New Thread on User Banning" mod- it makes a new thread.
Here's a copy of the code to make a new thread... I got it off a tutorial somewhere around here that was for 3.x but the code is the same. Code:
$bop5onban_fid = 2; //Forum ID for new thread //Set new thread details... $banthread =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $foruminfo = fetch_foruminfo($bop5onban_fid); $threadinfo = array(); $forumid = $bop5onban_fid; //Set some thread/post settings $bop5postip = "127.0.0.1"; $bop5allowsmilie = '1'; $bop5visible = 1; $banthread->set_info('forum', $foruminfo); $banthread->set_info('thread', $threadinfo); $banthread->setr('forumid', $forumid); $banthread->setr('userid', $bop5onban_uid); $banthread->setr('pagetext', $bop5onban_text); $banthread->setr('title', $bop5onban_title); $banthread->set('iconid', $vbulletin->options['bop5onban_icon']); $banthread->set('allowsmilie', $bop5allowsmilie); $banthread->set('visible', $bop5visible); $banthread->set('ipaddress', $bop5postip); $banthread->set('showsignature', $vbulletin->options['bop5onban_sig']); $banthread->pre_save(); if(count($banthread->errors) < 1) { $threadid = $banthread->save(); unset($banthread); build_thread_counters($banthread); } else { print "Error making new thread! " . $banthread->errors[0] . $banthread->errors[1] . $banthread->errors[2] ; } build_forum_counters($forumid); // end make thread code |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|