1

あるページで非常に奇妙な問題が発生しています (他の場所では発生していないようです)。

バリデーターに直接入力してページソースをコピペすると有効です。

しかし、URI を使用すると、ソースの doctype の上に次の 2 行があるように見えるため、あらゆる種類のエラーが発生します。

<!DOCTYPE html><br />
<b>Notice</b>: Undefined index: user_id in <b>[path]</b> on line <b>11</b><br />

11号線は

$userid = $_SESSION['user_id'];

print_r($_SESSION);user_id がそこにあり、正しい場合。

バリデーターはこれらのエラーをどこから取得しており、修正するにはどうすればよいですか?

編集:これはその前のコードです

<?php
    if(!isset($filepath)){
        $filepath = '../';
    }

    $lastseen = 'chatting away on the forums';
    include($filepath . 'includes/header.inc.php');

    print_r($_SESSION); //this displays Array ( [user_id] => 39 [name] => theatre [staff] => officer [logintime] => 8:46pm [upgrade] => undead ) exactly as it should

    $userid = $_SESSION['user_id']; //Line 11

if(isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'] > 0)){
    $boardid = (int) $_GET['id'];
}

/* Validate form submission */
if(($_SERVER['REQUEST_METHOD'] == 'POST') && ($_SERVER['HTTP_HOST'] == 'zombiesim.net') && isset($_POST['postcheck']) && ($_POST['postcheck'] == 'yes')){
    //a bunch of other form validation type stuff, but it doesn't even get here
    }
    ?>
    <!doctype html>
    <html dir="ltr" lang="en-US">
    <head>
    <meta charset="utf-8" />
    <!-- other meta tags, title, and link tags here -->
    <?php
    include($filepath . 'includes/pagehead.inc.php');
    ?>

ここに header.inc.php があります

    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);

    /* Start sessions and output buffering */
    session_start();
    ob_start();

    /* Include Functions */
include_once($filepath . 'includes/functions.inc.php');

/* Definte Referrer URL for Form Validation */
DEFINE('LASTURL', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);

/* If logged in, update last seen */
if(isset($_SESSION['user_id']) && is_numeric($_SESSION['user_id'])){
    $userid = (int) $_SESSION['user_id'];
    include($filepath . 'dbupdate.inc.php');
    $now = time();
    $now = date("Y-m-d H:i:s", $now);
    $seenq = "UPDATE users SET lastseen='" . $now . "', lastseenat='" . $lastseen . "' WHERE user_id=$userid";
    $seenr = mysqli_query($dbupdate, $seenq);
}

そしてここに pagehead.inc.php があります

<!-- Javascript for Google Analytics tracking -->
<script type="text/javascript" src="<?php echo $filepath; ?>js/analytics.js"></script>
</head>

<body>
<!--then begins the navigation and ends with the opening div for the main content-->
4

1 に答える 1