I am writing a plugin for vbulletin, which includes creating a new thread – the query below is what I have done. The query runs perfectly in phpmyadmin, but is not executed when ran within the php file; no error was reported. Can anyone tell me how to solve this problem? Thank you very much!
mysql_query("INSERT INTO `thread` (`threadid`, `title`, `prefixid`, `firstpostid`, `lastpostid`, `lastpost`, `forumid`, `pollid`, `open`, `replycount`, `hiddencount`, `deletedcount`, `postusername`, `postuserid`, `lastposter`, `dateline`, `views`, `iconid`, `notes`, `visible`, `sticky`, `votenum`, `votetotal`, `attach`, `similar`, `taglist`, `awardedcredits`, `threaddesc`)
VALUES (NULL, '$mname', '', '0', '0', '0', '$M4rumid', '0', '1', '0', '0', '0', '$username', '$userid', '$username', '$date', '0', '0', '', '1', '0', '0', '0', '0', '', NULL, '0', 'awarded');
SET @threadid = LAST_INSERT_ID();
INSERT INTO `post` (`postid`, `threadid`, `parentid`, `username`, `userid`, `title`, `dateline`, `pagetext`, `allowsmilie`, `showsignature`, `ipaddress`, `iconid`, `visible`, `attach`, `infraction`, `reportthreadid`, `kbank`, `post_thanks_amount`)
VALUES (NULL, @threadid, '0', '$username', '$userid', '$mname', '$date', '$postcontent', '1', '1', '', '0', '1', '0', '0', '0', '0.00', '0');
SET @postid = LAST_INSERT_ID();
UPDATE `thread`
SET `firstpostid` = @postid,
`lastpostid` = @postid,
`lastpost` = '$date'
WHERE `threadid` = @threadid;
UPDATE `user`
SET `posts` = `posts`+1
WHERE `userid` = '$userid';");
Those are 4 queries and not 1.
From The PHP Manual on mysql_query :
And by the way, on the same page:
And by the way here is how VBulletin wants you to interact with its database: Vbulletin SQL query syntax.