2013-01-18 49 views
0

我正在爲vbulletin編寫插件,其中包括創建新線程 - 下面的查詢是我所做的。查詢在phpmyadmin中完美運行,但在php文件中運行時不會執行;沒有錯誤報告。誰能告訴我如何解決這個問題?非常感謝你!查詢不會在vbulletin中執行php

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';"); 

回答

0

那些是4次的查詢,而不是1。

PHP Manual on mysql_query

的mysql_query()發送一個唯一查詢(多個查詢不支持)到當前活動的數據庫在與指定的link_identifier關聯的服務器上。

順便說一下,在同一頁上:

這個擴展不贊成PHP 5.5.0的,並會在將來被移除。相反,應該使用MySQLi或PDO_MySQL擴展。

順便說一下,VBulletin希望您與其數據庫交互的方式如下:Vbulletin SQL query syntax

+0

謝謝,我不知道._。有無論如何運行多個查詢? – user1985916

+0

是的,用sgeddes建議的** mysqli_multi_query **,但你應該堅持使用vBulletin語法。 –

+0

謝謝,還有一個問題,如果我繼續使用mysql_query(),有什麼問題嗎? – user1985916

0

我認爲你的問題是你不能用mysql_query運行多個查詢。檢查此鏈接了:

http://php.net/manual/en/function.mysql-query.php

而且從他們的網站:

的mysql_query()發送一個唯一的查詢(多個查詢不 支持)當前激活的數據庫是 在服務器上與指定的link_identifier關聯。

嘗試使用mysqli_multi_query代替:

http://php.net/manual/en/mysqli.multi-query.php

好運。

+0

非常感謝,但它比我想象的更復雜,我想我必須將它分成4個單一的mysql_query ... – user1985916