0

I'm having a problem I've been trying to solve for 3 weeks, and have gotten almost nowhere.

My web app was working perfectly fine, until one day it stopped working entirely because my header.php file is royally messed up.

Basically, the problem is:

My header.php file is displaying NOTHING (View Source displays nothing) and the page is completely white. I have turned on all error reporting, and tried echoing things at the top of the page, but NOTHING works until I comment out a few variables in an if statement (see below)

The following are the first few lines of code of my header.php file.

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);


echo("TEST");

session_start();


if(isset($_SESSION['username'])){ //VARIABLES WITHIN THIS STATEMENT CAUSE ERROR
    $username = $_SESSION['username'];
    $email = $_SESSION['email'];
    $title = $_SESSION['title'];
    $id = $_SESSION['id'];
    $role = $_SESSION['role'];
    $fullname = $_SESSION['fullname'];
    $labname = $_SESSION['labname'];
    $date_official = $_SESSION['date'];
    $permission = $_SESSION['permission'];
    $avatar = $_SESSION['avatar'];
    $usr_ip = $_SERVER['REMOTE_ADDR'];
    $isLogged = true;

}
else
{
    $isLogged = false;
    echo("Unlogged.");
}


if($isLogged)
{
    if($permission == 7 || $permission == 1 || $permission == 2){

    echo <<<_END

<!DOCTYPE html>
<html lang="en">
<head>
...file truncated for simplicity.

If I comment out $permission and $role, the echo "TEST" runs, but the rest of the page doesn't. I'm kind of a PHP noob, but honestly I've used PHP for almost 5 years now and have never encountered anything like this.

I greatly appreciate ANY help. Thank you so much.

Cheers

EDIT** I have been asked to paste my entire code:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);


session_start();
echo("TEST");

if(isset($_SESSION['username'])){
    $username = $_SESSION['username'];
    $email = $_SESSION['email'];
    $title = $_SESSION['title'];
    $id = $_SESSION['id'];
    $role = $_SESSION['role'];
    $fullname = $_SESSION['fullname'];
    $labname = $_SESSION['labname'];
    $date_official = $_SESSION['date'];
    $permission = $_SESSION['permission'];
    $avatar = $_SESSION['avatar'];
    $usr_ip = $_SERVER['REMOTE_ADDR'];
    $isLogged = true;

}
else
{
    $isLogged = true;
    echo("Unlogged.");
}


if($isLogged)
{
    if($permission == 7 || $permission == 1 || $permission == 2){

        echo <<<_END

<!DOCTYPE html>
<html lang="en">
<head>
    <!--CHARSET-->
    <meta charset="UTF-8">

    <!--FAVICON-->
    <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />

    <!--INTERNAL STYLING-->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/core_styles.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/core_styles.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" href="css/calendar.css" />
    <link rel="stylesheet" type="text/css" href="css/font-awesome.css">
    <link rel="stylesheet" href="css/dropzone.css">

    <!--JQUERY AND JQUERY UI-->
    <script src="js/jquery-2.2.3.min.js"></script>
    <script src="js/jquery-ui.min.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/smoothness/jquery-ui.css"    />


    <!--INTERNAL SCRIPTS-->
    <script src="js/functions.js"></script>
    <script src="js/account.js"></script>
    <script src="js/storage.js"></script>
    <script src="js/notebook.js"></script>
    <script src="js/protocol.js"></script>
    <script src="js/calendar.js"></script>
    <script src="js/members.js"></script>
    <script src="js/administration.js"></script>
    <script src="js/dash.js"></script>

    <!--CHARTS-->
    <script src="js/Chart.min.js"></script>

    <!--DROPZONE-->
    <script src="js/dropzone.js"></script>

    <!--BOOTSTRAP-->
    <link type="text/css" href="css/bootstrap.css" rel="stylesheet">
    <script src="js/bootstrap.min.js"></script>

    <!--SUMMERNOTE-->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.1/summernote.js"></script>
    <link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.1/summernote.css" rel="stylesheet">

    <!--TOOLTIPS-->
    <link rel="stylesheet" type="text/css" href="css/tooltipster.css" />
    <script type="text/javascript" src="js/jquery.tooltipster.min.js"></script>


    <title>FMAX ($labname)</title>
</head>
<body>
<div id="appWrapper">
<div id="point_prompt"></div>
    <div id="appPanelLeft">

        <!--LOGO CONTAINER-->
        <div id="appLogo" class="subPanel">
            <span class="logoF logoFont textDeny">F </span><span class="logoMax logoFont textDeny">M A X</span>
        </div>

        <!--PROFILE PICTURE CONTAINER-->
        <div id="subPanel_0" class="subPanel">
            <div class="profilePicture" style="background-image: url($avatar)"></div>
            <div class="ta_center">
                <span id="pnl_username" class="regTextPanelB">$fullname</span>
                <br/>
                <span id="pnl_permis" class="hintTextA">$role</span>
                <br/>
                <span id="pnl_degree" class="hintTextA">$title</span>
                <br/>
            </div>
        </div>

        <!--MAIN NAV CONTAINER-->
        <div id="subPanel_1" class="subPanel">
        <table id="navTable">
        <tr>
            <td>
            <div data-value="0" class="pnlNavBtn">
                <span class="fa fa-home fa-3x fa-fw myBlue"></span><br/>
                <span class="regTextPanelA">Dashboard</span>
            </div>
            </td>
            <td>
            <div data-value="1" class="pnlNavBtn">
                <span class="fa fa-book fa-3x fa-fw myPurple"></span>
                <span class="regTextPanelA">Notebook</span>
            </div></td>
        </tr>

        <tr>
            <td>
            <div data-value="2" class="pnlNavBtn">
                <span class="fa fa-shopping-cart fa-3x fa-fw myYellow"></span>
                <span class="regTextPanelA">Orders</span>
            </div>
            </td>

            <td>
            <div data-value="3" class="pnlNavBtn">
                <span class="fa fa-list fa-3x fa-fw myOrange"></span>
                <span class="regTextPanelA">Protocols</span>
            </div>
            </td>
        </tr>

        <tr>
            <td>
            <div data-value="4" class="pnlNavBtn">
                <span class="fa fa-database fa-3x fa-fw myGreen"></span>
                <span class="regTextPanelA">Storage</span>
            </div>
            </td>

            <td>
            <div data-value="5" class="pnlNavBtn">
                <span class="fa fa-users fa-3x fa-fw myDarkBlue"></span>
                <span class="regTextPanelA">Members</span>
            </div>
            </td>
        </tr>

        <tr>
            <td>
            <div data-value="6" class="pnlNavBtn">
                <span class="fa fa-calendar fa-3x fa-fw myYellow"></span>
                <span class="regTextPanelA">Calendar</span>
            </div>
            </td>
            <td>
            <div data-value="8" class="pnlNavBtn">
                    <span class="fa fa-lock fa-3x fa-fw myRose"></span>
                    <span class="regTextPanelA">Administration</span>
                </div>
            </td>
        </tr>

        </table>

        </div>

        <!--USER NAV CONTAINER-->
        <div id="subPanel_2" class="subPanel">
            <span class="hintTextA">User</span>
            <br/>
            <br/>
            <div data-value="9" class="pnlNavBtn list">
                <span class="fa fa-user fa-fw myBlue"></span>
                <span class="regTextPanelA">Account</span>
            </div>
            <a href="logout.php"><div class="pnlNavBtn list">
                <span class="fa fa-sign-out fa-fw myBlue"></span>
                <span class="regTextPanelA">Logout</span>
            </div>
            </a>

        </div>

        <!--LAB MODULES CONTAINER-->
        <div id="subPanel_3" class="subPanel">
            <span class="hintTextA">Public Lab Page</span>
            <br/>
            <br/>
            <div data-value="10" class="pnlNavBtn list">
                <span class="fa fa-edit fa-fw myBlue"></span>
                <span class="regTextPanelA">Edit Modules</span>
            </div>

        </div>



    </div>
    <div id="appWindow">

        <!--TOOLBAR -->
        <div id="appToolbar" class="row">

            <nav class="navToolbar">
                <ul>
                    <li id="app_msgs_btn"><span class="fa fa-lg fa-envelope-o myDarkBlue"></span>  <span class="notificationHint small" id="inboxHint">0</span></li>
                    <li id="app_notif_btn"><span class="fa fa-lg fa-exclamation-circle myRose"></span>  <span class="notificationHint small" id="notifHint">0</span></li>
                <ul>
            </nav>

        </div>

        <div id="notificationPane">

        <div class="notification">
            <span class="fa fa-fw fa-exclamation myRed"></span> Lorem ipsum dolor sit amet.
        </div>
                <div class="notification">
            <span class="fa fa-fw fa-exclamation myRed"></span> If you type for long enough, your text might just extend two lines.
        </div>
                <div class="notification">
            <span class="fa fa-fw fa-exclamation myRed"></span> Some Content.
        </div>
                <div class="notification">
            <span class="fa fa-fw fa-exclamation myRed"></span> Some Content.
        </div>
                <div class="notification read">
            <span class="fa fa-fw fa-exclamation myRed"></span> Some Content.
        </div>

        </div>

_END;

    }
}
else{
    echo("Error.");
}
Vranvs
  • 1,411
  • 4
  • 17
  • 38
  • `...file truncated for simplicity.` don't do that, it's possible the error lies in the truncated code. – rjdown Jul 09 '16 at 02:49
  • Okay, I will paste the entire thing. – Vranvs Jul 09 '16 at 02:49
  • I noticed a difference between the two code blocks. The second always sets $isLogged to true. Part of your debugging attempt? – rjdown Jul 09 '16 at 02:53
  • Yes, I'm playing around whilst this comment is up trying to fix things. Doesn't work with $isLogged = true, or $isLogged = false. – Vranvs Jul 09 '16 at 02:54
  • Works for me, aside from the obvious undefined index warnings – rjdown Jul 09 '16 at 02:56
  • Really?? Is it possibly an error in my ini file? – Vranvs Jul 09 '16 at 02:57
  • Maybe. Check your Apache error logs – rjdown Jul 09 '16 at 02:57
  • [09-Jul-2016 02:59:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.5.12/ext/php_ldap.dll' - The specified module could not be found. in Unknown on line 0 [09-Jul-2016 04:59:49 Europe/Paris] PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 4718 bytes) in C:\wamp\www\schryverslab\header.php on line 111 – Vranvs Jul 09 '16 at 03:00
  • I changed my memory back to the default 128MB, restarted the server. Still the same issue. This DOES remind me however that I increased memory to write a separate script, and thats likely when all of this started. I upped memory_limit to a huge number. – Vranvs Jul 09 '16 at 03:02
  • If you aren't doing anything particularly memory-intensive, that fatal error is usually the result of an infinite loop. There aren't any in the code you've pasted, so are you including it from another script? – rjdown Jul 09 '16 at 03:02
  • YES! I got it working. Had to change my memory limit to: memory_limit = 536870912. Thank you so much my friend!!! – Vranvs Jul 09 '16 at 03:05
  • That seems excessive considering the code, glad it's working though :) – rjdown Jul 09 '16 at 03:06
  • It's in bytes; so that's the default 128MB. As per: http://stackoverflow.com/questions/16175153/allowed-memory-size-of-262144-bytes-exhausted-tried-to-allocate-24576-bytes. Feel free to post an answer and I will accept it as soon as I can. Thanks!!! – Vranvs Jul 09 '16 at 03:10
  • 2
    You solved it yourself, best to answer it yourself and close it – rjdown Jul 09 '16 at 03:13

0 Answers0