I am getting an undefined offset error after moving files into different folders

34
April 16, 2019, at 10:00 AM

OK so I have a folder that looks like this..

loginsystem/
        homepages/
             home14.php
        includes/
             dbh.inc.php 
        header.php
        index.php

...When a user creates a new account on my website, they get a personal homepage (ex. homepages/home14). I want to include the header I use for my index.php file inside of the home14.php file. When I try to reroute the required location for home14.php, I get the undefined offset errors. The errors say that problems are on lines 29 and 30 of the header.php file, but it's working perfectly fine for index.php.

When I link to the header in my home14.php file, I typed (require "../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();
    }
?>

Again, all I want is the same header I use in the index.php file to be used in the home14.php file. I am only getting the undefined offset when I require it in the home14.php and not when I use it with index.php

READ ALSO
ErrorException htmlspecialchars() expects parameter 1 to be string, array given

ErrorException htmlspecialchars() expects parameter 1 to be string, array given

I want to get data "report_to" from databaseBut i got error when I try to print variable in my view page

29
How to add Attachment field compulsory in WordPress Add to Cart Page [on hold]

How to add Attachment field compulsory in WordPress Add to Cart Page [on hold]

i have added File attachment field in my add to cart page but if someone did not upload their attachment they are still able to place their orderNow i want to make attachment field compulsory that no one place their order successfully without uploading...

43
synchronous dispatching a job how?

synchronous dispatching a job how?

I am developing a multi tenancy app with laravel 58 and I am using this to set related tenant ID for the job but when I dispatch jobs from console like this

26
header not work shows error header already sent

header not work shows error header already sent

I used header function to sent session values to another page but when I used this code is shows headers already sentI also don't give any blank spaces before starting code and ending code

33