PHP 包括();不包括文件


PHP include(); not including file

我正在尝试包含一个单独的代码片段来从MySQL表中获取数据。我的页面代码:

<?php session_start(); ?>
<html>
    <?php include('head.php'); ?>
    <body>
        <?php include('navigation.php'); ?>
        <div id="container">
        <?php
            $section = "Movies";
            print "THIS IS A TEST";
            //$_SESSION['sectiontemp'] = $section;
            include('section-grabinfo.php');
            include('footer.php');
        ?>
        </div>
    </body>
</html>

我的部分抓取信息.php页面:

<?php
            print "THIS IS A TEST";
            $sql = mysqli_query($conn, "SELECT * FROM article JOIN person ON article.author=person.id WHERE section='".$section."' AND status=1 ORDER BY aid DESC LIMIT 1;");
            if ($sql == 'false') {
                print "SQL doesn't work";
            }
            elseif ($sql == 'true') {
                print "Works all fine";
            }
            else {
                print "Wrong code.";
            }
            while ($row = mysqli_fetch_assoc($sql)) {
                $title = $row['title'];
                $preview = $row['preview'];
                $author = $row['name'];
                $person_id = $row['author'];
                $id = $row['id'];
                $username = $row['username'];
                include('featured-article.php');
            }
            //LEAVE SPACE FOR ADS
?>
<div id="secondaryArticleSection">
<?php
            $sql2 = mysqli_query($conn, "SELECT * FROM article JOIN person ON article.author=person.id WHERE aid<(SELECT max(aid) FROM article WHERE section='."$section."' AND status=1) AND section='".$section."' AND status=1 ORDER BY aid DESC;");
            while ($row = mysqli_fetch_assoc($sql2)) {
                $title = $row['title'];
                $preview = $row['preview'];
                $author = $row['name'];
                $person_id = $row['author'];
                $id = $row['id'];
                $username = $row['username'];
                include('secondary-article.php');
            }
?>
</div>

基本上我的问题是部分抓取信息.php页脚.php没有包含在主页上。请记住,当我在笔记本电脑(不是我当前使用的服务器)上使用它时,这完全有效。谢谢。

如果它真的是一个包含麻烦,你可以尝试以这种方式包含

<?php include(__DIR__.'/head.php'); ?>