Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
数据库插入前的php头重定向_Php_Header - Fatal编程技术网

数据库插入前的php头重定向

数据库插入前的php头重定向,php,header,Php,Header,我的php标题(“Location:example.com”)似乎在插入数据库查询之前重定向(在一台计算机上)。这很奇怪,因为我在运行头之前检查数据库是否返回true 这对我来说很好,但在我的朋友系统上,它似乎重定向得太早了。如果我删除header()函数和die()。它很好 这被编码为mediawiki的扩展。我不知道问题是否在这里。Mediawiki有自己的数据库查询类和函数 if ($_GET['action'] == 'postReply') { $threadid = $_PO

我的php
标题(“Location:example.com”)
似乎在插入数据库查询之前重定向(在一台计算机上)。这很奇怪,因为我在运行头之前检查数据库是否返回true

这对我来说很好,但在我的朋友系统上,它似乎重定向得太早了。如果我删除
header()
函数和
die()
。它很好

这被编码为mediawiki的扩展。我不知道问题是否在这里。Mediawiki有自己的数据库查询类和函数

if ($_GET['action'] == 'postReply') {
    $threadid = $_POST['t_id'];
    $content = $_POST['content'];
    $postReply = postThreadReply($threadid, $username, $userid, 
$content);
    if ($postReply == 1) {
        header("Location: ?title=" . $title . "&t=" . $threadid . '#last');
        die();
    }
此代码经过修改,以便于阅读

这是标头过早重定向的主要功能。 postThreadReply()执行一些检查并插入到正确的表中<代码>postThreadReply()如果每个查询返回true,则返回1

我认为不需要更多的代码,但如果需要,请告诉我。:)

所以我想知道我的代码是否有问题,或者在Mediawiki中是否有问题?或者这是
header()
函数的已知问题?有没有别的方法我可以试试

这是我在这里的第一个问题,如果我的问题不清楚或者我没有提供足够的代码,我很抱歉

编辑:

postThreadReply()

insertPost()

}


^MediaWiki的查询方式。

您能告诉我们postThreadReply的代码吗?@KasiaGogolek现在添加了代码。它主要调用其他函数tho。我还可以补充一点,这个问题发生在postThread和reportThread的函数上。这与上面的有点相似
function postThreadReply($threadid, $username, $userid, $t_post) {
    if (postExistDuplicate($threadid, $username, $userid, $t_post)) return 3;
    if (!threadExist($threadid)) return 4;
    $inpost = insertPost($threadid, $username, $userid, $t_post);
    if (!$inpost) return 2;
    return 1;
}
function insertPost($threadid, $username, $userid, $t_post) {
$datetime = date_create()->format('Y-m-d H:i:s');
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->insert( 
    'disc_posts', 
    array(
        'id' => null,
        'thread_id' => $threadid,
        'author' => $username,
        'author_id' => $userid,
        'content' => $t_post,
        'posted' => $datetime,
        'deleted' => 0
    )
);
return $res;