Welcome to WebmasterWorld Guest from 54.224.17.208

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Cannot modify header issue

     
4:31 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I'm getting a Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/mfa/mfa/inc/db.inc:1) in /usr/www/users/mfa/mfa/newmember.php on line 199
issue

If I open my db.inc file in notepad it looks like this
<?phpsession_start();require_once "DB.php";require_once "HTML/Template/IT.php";

The full file looks like this
<?php
$username = "root";
$password = "sqlserver";
$hostname = "localhost";
$dbname = "mfa_Test1";


//$username = "406_s09_team2";
//$password = "406_s09_team2";
//$hostname = "localhost";
//$dbname = "406_s09_team2";

function clean($array, $index, $maxlength, $connection){
if (isset($array["{$index}"])){
$input = substr($array["{$index}"], 0, $maxlength);
//$input = $connection->escapeSimple($input);
return ($input);
}
return NULL;
}
function check_email_address($email) {
// First, we check that there's one @ symbol,
// and that the lengths are right.
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters
// in one section or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if
(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
&#8618;'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
return false;
}
}
// Check if domain is IP. If not,
// it should be valid domain name
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
&#8618;([A-Za-z0-9]+))$",
$domain_array[$i])) {
return false;
}
}
}
return true;
} // check_email_address
?>

What am I missing here? I'll note that on my windows box, the page runs fine, but when I upload it via ftp to a linux server, I get the error.
4:49 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Suppose its not the best option, however it works for me when I get the same error while using headers (however cant see any header in your script)
I start the page with:
<?php
ob_start();

and end the php with
ob_end_flush();
?>

Sure some gury will tell me this is not correct :)
5:13 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I actually tried that just to see if it would fix the issue. It didn't. Unless you build in your own error reporting, you are correct, it's not the proper way to do things.
5:14 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Wait, I was wrong, adding the ob_start() fixed it. I'll just throw in an if statement to catch the errors so I know if I have one.
5:41 pm on May 23, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you ever can't obviously find anything outside of

<?php

and

?>

...in a .php file that shows output starting from it at line 1, a possible cause is that the file has been saved with a byte order mark [en.wikipedia.org] (BOM) prepended somewhere along the line.

Any text editor that may have prepended a BOM should have an option on its Save As... dialog for the desired character encoding without BOM e.g.

UTF-8 NO BOM

...and the file should then be interpreted by PHP as expected.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month