嘿,我正在通过 lynda.com 的一些教程学习 PHP。在本教程中,我们正在制作一个 CMS。我按照教程中的步骤进行操作,甚至从 lynda.com 获得了文件,并且完全一样,但是在教程中它可以工作,当我这样做时,标题位置不起作用。
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php error_reporting(E_ALL); ini_set('display_errors', 'On'); ?>
<?php
$menu_name = $_POST['menu_name'];
$position = $_POST['position'];
$visible = $_POST['visible'];
?>
<?php
$query = "INSERT INTO subjects (
menu_name, position, visible
) VALUES (
'{$menu_name}', {$position}, {$visible}
)";
$result = mysql_query($query, $connection);
if ($result) {
// Success!
header("location:content.php");
exit;
} else {
// Display error message.
echo "<p>Subject creation failed.</p>";
echo "<p>" . mysql_error() . "</p>";
}
?>
<?php mysql_close($connection); ?>
我得到的错误如下
Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Widgetcorp/create_subject.php:5) in /Applications/MAMP/htdocs/Widgetcorp/create_subject.php on line 19