错误代码,并不会在PHP中工作
我之前发布了一些东西,这次我会发布所有这些。我收到错误消息,并且当我尝试在本地主机上将其拉出时,它不会显示。 代码如下:
这个是includeindex.php
if ($_POST['submit'] != "") {
if ($_POST['name'] != "") {
session_start();
$_SESSION['name'] = $_POST['name'];
TopNavigation("PHP Includes Example - ECA236", "PHP Includes", $_SESSION['name']);
} else {
header("Location:includindex.php");
exit;
}
} else {
TopNavigation("PHP Includes Example - ECA236", "PHP Includes");
echo "<div class="formtable">n";
echo "<br>";
echo "<form action="" . $PHP_SELF . "" method="post">n";
echo "Please enter your name:<input type="text" name="name">n";
echo "<input type="submit" class="btnSubmit" value="Enter" name="submit">n";
echo "</form>n";
echo "<br>";
echo "</div>n";
Footer();
}
?>
这是头
<?php
function TopNavigation($pagetitle, $pageheading, $username = '') {
echo "<html>n";
echo " <head>n";
echo " <title>" . $pagetitle . "</title>n";
echo " <link href="../style.css" type="text/css" rel="stylesheet">";
echo " </head>n";
echo " <body>";
echo " <h1>" . $pageheading . "</h1>n";
echo " <hr>n";
echo " <p class="tiny">" . date("F j,Y") . "</p>";
if ($username != '') {
echo "<div align="center">n";
echo "<a href="includeindex.php">Use a different name</a> | <a href="about.php">About</a> | <a href="signout.php">Signout</a>n";
echo "</div>n";
echo "<p>Welcome. " . $username . "!";
}
}
function Footer() {
echo "</body>n";
echo "</html>n";
}
?>
这个是about.php
<?php
session_start();
include("include/header.php");
if (!isset($_SESSION['name'])) {;
header("Location:includeindex.php");
exit;
} else {
TopNavigation("About Me -ECA236", "About Me", $_SESSION['name']);
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>"n;
echo " < p>I been married for 5 years but been with my husband for 11 years </p > "n;
echo "<p > I am attending college for Computer Programming and Database Mangament </p > "n;
echo "<p > After I get done with this degree I am want to go back for Web Design </p > "n;
echo "<p > since half my classes are web design now . I enjoy camping,bon fires and </p > "n;
echo "<p > playing video games, hanging out with friends and family .</p > "n;
Footer();
}
?>
这是signout.php
<?php
session_start();
if (isset($_SESSION['name'])) {
session_destroy();
session_start();
}
header("Location:includeindex.php");
exit;
?>
我无法让它出现并工作。 我不知道为什么它不这样做。 有人可以帮帮我吗。
无论我修复了什么,我都会收到错误,并且在网上查看时它不会显示。
这里是我得到的错误:注意:未定义的变量:第19行中的C: wamp www includeindex.php中的PHP_SELF未定义索引:在第4行中的C: wamp www includeindex.php中提交警告:include(include / header.php)[function.include]:未能打开流:在第3行的C: wamp www about.php中没有这样的文件或目录警告:include()[function.include]:打开'include /在C: wamp www about.php上包含(include_path ='.; C: php pear')的header.php'致命错误:调用未定义函数TopNavigation()in C: wamp 第9行的www about.php
TopNavigation()
函数中的所有echo
语句仍然被错误地引用。 而不是"n;
它们应该以n";
结尾n";
// Wrong
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>"n;
// Should be:
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>n";
---^^^^
在您的php.ini中将display_errors = Off更改为display_errors = On
链接地址: http://www.djcxy.com/p/69661.html上一篇: Errors code and wont work in PHP
下一篇: Frontcontroller help