作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我知道在 php 代码之前不应该有空格。然而,我的代码在实时服务器上给我以下错误,但在我的测试 Apache 服务器上没有:
Warning: Cannot modify header information - headers already sent by (output started at /home/mydomain/public_html/parts/includes/dbinfo.inc.php:5) in /home/mydomain/public_html/parts/update_part.php on line 55
我已经尝试删除 functions.inc.php
仍然遇到同样的问题。 以下是涉及的两段代码:a) 数据库信息.inc.php
<?php
$username="myusername";
$password="mypassword";
$database="mydatabase";
?>
b) update_part.php
<?php
include("./includes/dbinfo.inc.php");
include("./includes/functions.inc.php");
mysql_connect("localhost","$username","$password") or die("Error: ".mysqlerror());
mysql_select_db("$database");
//get the variables we transmitted from the form
$part_id = $_POST['part_id'];
$part_manufacturer = $_POST['part_manufacturer'];
$part_descr = $_POST['part_descr'];
$part_price = $_POST['part_price'];
$part_code = $_POST['part_code'];
$part_status = $_POST['part_status'];
$part_image = $_POST['part_image'];
$part_cat = $_POST['part_cat'];
$ave_mth_usage = $_POST['ave_mth_usage'];
$reorder_level = $_POST['reorder_level'];
$reorder_qty = $_POST['reorder_qty'];
$other_item_details = $_POST['other_item_details'];
$part_stock_taking_date = $_POST['part_stock_taking_date'];
$part_qty_in_stock = $_POST['part_qty_in_stock'];
$part_manufacturer = mysql_real_escape_string($part_manufacturer);
$part_descr = mysql_real_escape_string($part_descr);
$part_code = mysql_real_escape_string($part_code);
$part_status = mysql_real_escape_string($part_status);
$part_cat = mysql_real_escape_string($part_cat);
$other_item_details = mysql_real_escape_string($other_item_details);
//replace TestTable with the name of your table
$sql =
"UPDATE part SET
part_manufacturer = '$part_manufacturer',
part_descr = '$part_descr',
part_price = '$part_price',
part_code = '$part_code',
part_status = '$part_status',
part_image = '$part_image',
part_cat = '$part_cat',
ave_mth_usage = '$ave_mth_usage',
reorder_level = '$reorder_level',
reorder_qty = '$reorder_qty',
other_item_details = '$other_item_details',
part_stock_taking_date = '$part_stock_taking_date',
part_qty_in_stock = '$part_qty_in_stock'
WHERE part_id = $part_id";
//mysql_query($sql) or die ("Error: ".mysql_error());
do_query($sql,__LINE__);
header("Location: ./view_parts.php");
?>
第 55 行的违规代码是 b) 最后一行之前的行,即
header("Location: ./view_parts.php");
有什么想法吗?
我是一名优秀的程序员,十分优秀!