homepage Welcome to WebmasterWorld Guest from 23.23.12.202
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Cannot modify header issue
andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4577097 posted 4:31 pm on May 23, 2013 (gmt 0)

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.

 

helenp

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4577097 posted 4:49 pm on May 23, 2013 (gmt 0)

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 :)

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4577097 posted 5:13 pm on May 23, 2013 (gmt 0)

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.

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4577097 posted 5:14 pm on May 23, 2013 (gmt 0)

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.

dmorison

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4577097 posted 5:41 pm on May 23, 2013 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved