0

我正在为 vbulletin 编写一个插件,其中包括创建一个新线程 - 下面的查询是我所做的。查询在 phpmyadmin 中完美运行,但在 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';");
4

2 回答 2

0

这些是 4 个查询,而不是 1 个。

来自mysql_query 的 PHP 手册

mysql_query() 向与指定链接标识符关联的服务器上当前活动的数据库发送一个唯一查询(不支持多个查询) 。

顺便说一句,在同一页面上:

此扩展自 PHP 5.5.0 起已弃用,并将在未来删除。相反,应该使用 MySQLi 或 PDO_MySQL 扩展。

顺便说一下,VBulletin 希望您如何与它的数据库进行交互:Vbulletin SQL 查询语法

于 2013-01-18T01:03:26.580 回答
0

我认为您的问题是您无法使用 mysql_query 运行多个查询。检查此链接:

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

从他们的网站:

mysql_query() 向与指定链接标识符关联的服务器上当前活动的数据库发送一个唯一查询(不支持多个查询)。

尝试使用 mysqli_multi_query 代替:

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

祝你好运。

于 2013-01-18T01:03:33.787 回答