将文件移到其他文件夹后出现未定义的偏移量错误

时间:2019-04-15 06:59:06

标签: php html css

好的,所以我有一个看起来像这样的文件夹。

loginsystem/
        homepages/
             home14.php

        includes/
             dbh.inc.php 

        header.php
        index.php

...当用户在我的网站上创建新帐户时,他们会获得一个个人主页(例如homepages / home14)。我想在home14.php文件中包含用于index.php文件的标头。当我尝试为home14.php重新路由所需的位置时,出现未定义的偏移量错误。错误表明问题出在header.php文件的第29行和第30行,但对于index.php来说,它的工作正常。

当我链接到home14.php文件中的标题时,我键入了(要求“ ../ header.php”;)

header.php

<?php  
    require 'includes/dbh.inc.php';
    session_start();
    date_default_timezone_set('America/Chicago');
    include 'includes/comments.inc.php';
?>
<!DOCTYPE html>
<html>
    <head>
</head>
        <div id="headerContainer">

<!-- If the user is logged in, set username and profile picture.-->

<?php 
                if (isset($_SESSION['userID'])) {
                    $id = $_SESSION['userID'];
                    $sqlImg = "SELECT * FROM profileimg WHERE userid='$id'";
                    $resultImg = mysqli_query($conn, $sqlImg);
                    while ($rowImg = mysqli_fetch_assoc($resultImg)) {      
                        if ($rowImg['status'] == 0) {
                            $filename = "profilepics/profile".$id."*";
                            $fileinfo = glob($filename);
       -------- LINE 29 --- $fileext = explode(".", $fileinfo[0]);
       -------- LINE 30 --- $fileactualext = $fileext[1];
                            echo "<div class=userPicture><img src='profilepics/profile".$id.".".$fileactualext."?".mt_rand()."'></div>";
                        }
                        else {
                            echo "<div class='userPicture'><img src='profilepics/noUser.png'></div>";
                        }
                    }

home14.php

<?php
    require "../header.php";
    if (isset($_SESSION['userID'])) {
        echo 
            "<div class='homeBody'>



            </div>";
        require "../footer.php";    
    } 
    else {
        header("Location: ../signup.php");
        exit();
    }

?>


同样,我想要的是与在home14.php文件中使用的index.php文件中使用的相同标头。我只有在home14.php中需要它时才得到未定义的偏移量,而与index.php一起使用时却没有得到

0 个答案:

没有答案