为什么在输入我的PHP代码后,我的网页无法加载?我的代码有什么问题吗?当我转到开发工具然后进入控制台时,它显示以下消息:
无法加载资源:服务器的响应状态为500(内部服务器错误)。
我是网页和PHP的新手。
下面是代码:
<?php
# here database details
$page_title = 'TP-HRG Centre';
include ('includes/header.html');
require ('mysqli_connect.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- <meta http-equiv="refresh" content="30"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
body {
height: 100%;
width: 100%;
background-image: url("TPHRG floorplan1.png");
background-repeat: no-repeat;
background-attachment: fixed;
/* background-position: center; */
background-size: 980px 400px, cover;
}
.robot_start_top {
top: 280px;
transition: top 2s;
}
.robot_start_left {
position: fixed;
left: 600px;
transition: all 2s;
}
.robot_end_left {
left: 570px;
}
.robot_end_top {
top: 180px;
}
.robot1_start_left {
position: fixed;
left: 570px;
transition: left 4s;
}
.robot1_end_left {
left: 520px;
}
.robot2_start_left {
position: fixed;
left: 520px;
transition: left 4s;
}
.robot2_end_left {
left: 470px;
}
.robot3_start_left {
position: fixed;
left: 470px;
transition: left 4s;
}
.robot3_end_left {
left: 420px;
}
.robot3_end_down {
top: 280px;
}
.robot3_end_right {
left: 600px;
}
</style>
</head>
<body onkeydown="move(event)">
<div class="robot_start_left robot_start_top" id="app">
<img id="robot" style= width:30px; height:40px" src="pic_8.PNG">
</div>
<script>
$(document).ready(function(){
document.getElementById("Tables").innerHTML = <?php echo $_REQUEST['id'];
var move = function(event) {
if (Tables === 1) {
const appDiv = document.getElementById("app");
setTimeout(function() {
appDiv.classList.add("robot_end_top");
}, 0);
setTimeout(function() {
appDiv.classList.add("robot_end_left");
}, 2000);
}
if (Tables === 2) {
const appDiv = document.getElementById("app");
setTimeout(function() {
appDiv.classList.add("robot_end_top");
}, 0);
setTimeout(function() {
appDiv.classList.add("robot1_end_left");
}, 2000);
}
if (Tables === 3) {
const appDiv = document.getElementById("app");
appDiv.classList.add("robot2_end_left");
}
if (Tables === 4) {
const appDiv = document.getElementById("app");
appDiv.classList.add("robot3_end_left");
}
if (Tables === 0) {
const appDiv = document.getElementById("app");
setTimeout(function() {
appDiv.classList.add("robot3_end_down");
}, 2000);
setTimeout(function() {
appDiv.classList.add("robot3_end_right");
}, 0)
setTimeout(function() { window.location.reload(true); }, 4000);
}
}
?>
}
</script>
</body>
</html>
答案 0 :(得分:1)
您的代码中存在语法错误。因为您已关闭display_errors
,并且PHP以非零的退出代码退出,所以Web服务器知道出了点问题,并返回了通用的HTTP 500错误响应状态代码。有关如何解决此问题的更多详细信息,请参见WSOD。
PHP Parse error: syntax error, unexpected 'var' (T_VAR), expecting end of file in file on line 92
这是您的代码中令人反感的行:
<script>
$(document).ready(function(){
document.getElementById("Tables").innerHTML = <?php echo $_REQUEST['id'];
var move = function(event) {
您可能忘记了<?php echo $_REQUEST['id'];
之后在那儿关闭PHP标记,因为您显然是在第二行上编写JavaScript。