I am aware that there should be no whitespace before the php code. However my code gives me the following error on the live server, but not on my test Apache server:
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
I have tried removing the functions.inc.php
still getting the same problem.
Below are the 2 pieces of code involved:
a) dbinfo.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");
?>
The offending code at line 55 is the line just before the final line of b) i.e.
header("Location: ./view_parts.php");
Any ideas?