在php页面中通过include引入php脚本,页面无法正确解析。
我的xq_note.php是html页面,diray_dispose.php是处理数据请求的php脚本,当我通过Include函数将diray_dispose.php脚本引入到xq_note.php页面中,浏览器会无法解析出xq_note.php页面。
正常解析画面:
当将diray_dispose.php通过include引入到xq_note.php页面中,画面如下:
无法正常解析出网页内容。
所以我想请教一下有大神知道是什么原因吗?该如何纠正过来?
xq_note.php代码:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>南风的博客-心情日记</title>
<link rel="shortcut icon" href="../img/ico_2.png"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="../css/index.css"/>
<link rel="stylesheet" href="../css/yemian_xiushi.css"/>
</head>
<body style="position: relative;">
<?php
error_reporting(0);
include '../access/diary_dispose.php';
?>
<!--导航栏-->
<div class="navbar navbar-inverse ">
<!--首页字体-->
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="../index.php">南风的博客</a>
</div>
<div class="navbar-collapse collapse" role="navigation">
<ul class="nav navbar-nav">
<li><a href="../index.php"><span class="glyphicon glyphicon-home"></span>  主页</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-leaf"></span>  
寄情文章<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="jq_love_article.php">爱情文章</a></li>
<li><a href="jq_family_article.php">亲情文章</a></li>
<li><a href="jq_friendship_article.php">友情文章</a></li>
</ul>
</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-hdd"></span>  
随性杂文
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="sx_life_article.php">生活随笔</a></li>
<li><a href="sx_school_article.php">校园文章</a></li>
<li><a href="sx_funny_article.php">搞笑文章</a></li>
</ul>
</li>
<li class="active"><a href="xq_note.php"><span class="glyphicon glyphicon-tasks""></span>  心情日记</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-cloud-download"></span>  
深度好文
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="deep_classic_article.php">经典文章</a></li>
<li><a href="deep_courage_article.php">励志美文</a></li>
<li><a href="deep_human_article.php">人生哲理</a></li>
</ul>
</li>
<li><a href="english_title.php"><span class="glyphicon glyphicon-heart"></span>  英语美文</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="../about.php"><span class="glyphicon glyphicon-paperclip"></span>  关于</a></li>
</ul>
</div>
</div>
</div>
<!--正文内容-->
<div id="con">
<!--当前位置-->
<p id="p_n">当前位置><a href="deep_classic_article.php">心情日记</a></p>
<ul class="list-group" id="list_group_xiu">
<?php foreach ($check_query as $value){ ?>
<li class="list-group-item">
<!--文章标题-->
[<a href="#" target="_blank"> <?php echo $value['title'];?></a> ]
<!--文章信息-->
<p>
日期: <?php echo $value['time'];?>
作者: <?php echo $value['author'];?>
阅读数: <?php echo $value['pageview'];?>
</p>
<!--文章正文-->
<h4>
<?php echo mb_substr($value['article'],0,200,utf8);?>......
</h4>
</li>
<?php };?>
</ul>
<!--分页按钮-->
<nav aria-label="...">
<ul class="pager">
<li class="previous"><a href="#"><span aria-hidden="true"></span>上一页</a></li>
<li class="next"><a href="#">下一页<span aria-hidden="true"></span></a></li>
</ul>
</nav>
</div>
<!--结尾内容-->
<div id="over_t">
<h4>
愿世界和平,愿雾霾不再来,
愿你我都勇敢执着。好的一并期待,
坏的一律包容,生活里的小幸运与一万
点伤害,爱与被爱,娓娓道来。
</h4>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
</body>
</html>
diray_dispose.php代码:
<?php
header("Content-Type:application/json;charset=utf-8");
//不进行错误提示
error_reporting(0);
$servername = "localhost";
$username = "root";
$password = "cyhcj1020";
// 创建连接
$conn = new mysqli($servername, $username, $password,"cyh_blog");
// 检测连接
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
//选择数据库
mysqli_select_db($conn,"cyh_blog");
//查询数据库中的某张数据表的全部数据
$check_query = mysqli_query($conn,"SELECT * FROM mood_diary");
//$result = mysqli_fetch_array($check_query);
mysqli_close($conn);
用的是bootstrap模板
浏览器不会报错,并且数据库中的数据在不能正常解析的页面中是可以显示出来的。
炎炎设计