breeze351
asked on
Error: "Header info already sent"
I know what the error means but I can't see it in the attached code.
I'm getting the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/langsyst/public_html /Lansco/Co mpany_Disp lay.php:30 ) in /home/langsyst/public_html /Lansco/Co mpany_Disp lay.php on line 46
Line 30 is "<?php
The include statements at the top have no "echo"
I've attached the code.
Company_Display.php
I'm getting the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/langsyst/public_html
Line 30 is "<?php
The include statements at the top have no "echo"
I've attached the code.
Company_Display.php
Header ("Location:$work"); can not be used after you have sent HTML content. After all, it is a header and must come before any content.
Here's an article from Ray on the topic.
https://www.experts-exchange.com/articles/4423/Warning-Cannot-modify-header-information-headers-already-sent.html
https://www.experts-exchange.com/articles/4423/Warning-Cannot-modify-header-information-headers-already-sent.html
ASKER
Where is the HTML content? I don't see it. I know that's the problem.
Lines 12-29 are all output - everything from <!DOCTYPE....> to the blank space after the <body> tag are all output. Just move it down to the bottom of that same file.
Maybe try it like this:
https://www.experts-exchange.com/articles/4423/Warning-Cannot-modify-header-information-headers-already-sent.html
<?php
ob_start();
// **************************************************************
// * Company_Add.php *
// * Keyin screen for company add/edit. *
// **************************************************************
// * Ver By Date Description *
// * 4.01 GJJD 04/25/16 Modify for PHP 5.6 *
// **************************************************************
include 'Session_Start.php';
include 'db_connect_inc.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Contact Display</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="NewCss.css">
<script type='text/javascript' src='//code.jquery.com/jquery-2.1.3.js'></script>
<script type="text/javascript" src="http://digitalbush.com/wp-content/uploads/2014/10/jquery.maskedinput.js"></script>
<script type="text/javascript">
function MM_goToURL()
{
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>
<body>
<?php
include 'Check_Login.php';
include 'Prog_Count_inc.php';
$Display_Phone = $_SESSION['South'];
$_SESSION['South'] = str_replace("/", "", $_SESSION['South']);
$_SESSION['South'] = str_replace("(", "", $_SESSION['South']);
$_SESSION['South'] = str_replace(")", "", $_SESSION['South']);
$_SESSION['South'] = str_replace(" ", "", $_SESSION['South']);
$_SESSION['South'] = str_replace("-", "", $_SESSION['South']);
$_SESSION['South'] = trim($_SESSION['South']);
$work = strlen($_SESSION['South']);
if ($work != 10)
{
$_SESSION['Message'] = "Invalid phone number entered!";
$_SESSION['Error'] = "Y";
$work = $_SESSION['Last_Page'];
Header ("Location:$work");
exit;
}
$Data = $_SESSION['South'];
include 'menu_inc.php';
Ref:https://www.experts-exchange.com/articles/4423/Warning-Cannot-modify-header-information-headers-already-sent.html
Hello???? You can NOT put Header ("Location:$work"); (line 51 in Ray's code) after any HTML content has been sent!!!! It is an HTTP header, it MUST come before any content is sent. That is the reason for the error message.
For reference: http://php.net/manual/en/function.header.php
For reference: http://php.net/manual/en/function.header.php
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Got it.
Thanks
Thanks
Open in new window
.Please remove the whitespace and re-test.