HTML验证程序,显示PHP不是';t显示
我在一个页面上遇到了一个非常奇怪的问题(这似乎在其他任何地方都不会发生) 当我通过直接输入将页面源复制并粘贴到验证器中时,它是有效的 但是,当使用URI时,它会出现各种错误,因为它的源代码似乎在我的doctype上面有两行代码:HTML验证程序,显示PHP不是';t显示,php,validation,html-validation,Php,Validation,Html Validation,我在一个页面上遇到了一个非常奇怪的问题(这似乎在其他任何地方都不会发生) 当我通过直接输入将页面源复制并粘贴到验证器中时,它是有效的 但是,当使用URI时,它会出现各种错误,因为它的源代码似乎在我的doctype上面有两行代码: <!DOCTYPE html><br /> <b>Notice</b>: Undefined index: user_id in <b>[path]</b> on line <b>11&
<!DOCTYPE html><br />
<b>Notice</b>: Undefined index: user_id in <b>[path]</b> on line <b>11</b><br />
当Iprint\r($\u会话)时代码>用户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');
?>
这里是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-->
您有$userid=(int)$\u会话['user\u id']
在header.inc.php
中,然后在$userid=$\u会话['user\u id']中重新声明它//第11行
删除它,或者为它设置不同的条件语句,因为它已经在另一个文件中声明。是session\u start()代码>加载?如果你没有,它是必需的。可能是重复的。我也有错误报告。完整的代码,就像所有的东西?这有点多,我想没有人真的想把它全部筛选一遍(特别是因为大部分内容与问题无关)。但是,我会把所有的东西都放到错误开始的地方代码>在header.inc.php中,它在前面被调用。会话变量已定义,并且在实际站点(以及使用相同设置的每个其他页面)上运行良好。我主要担心的是验证器发现了这个额外的doctype和错误消息,我不知道它是从哪里得到的,因为它肯定不在实际的页面源代码中。@qwigoqwaga好的,那么你在哪里写的“这是之前的代码”,这不是你现在正在使用的?@qwigoqwaga我想我知道发生了什么。您有$userid=(int)$\u会话['user\u id']
在header.inc.php
中,然后在$userid=$\u会话['user\u id']中重新声明它//第11行
第一个代码块是主页顶部的问题所在,是。第二个代码块是header.inc.php,第三个代码块是headstuff.inc.php(它实际上只是HTML,但我包含了它以防相关)@qwigoqwaga您刚才读过吗?
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);
}
<!-- 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-->