stockton Posted September 18, 2008 Share Posted September 18, 2008 I get the following error message:- Warning: Cannot modify header information - headers already sent by (output started at /var/www/www.stockton.co.za/doc/pm/functions.php:32) in /var/www/www.stockton.co.za/doc/pm/login.php on line 50 The code that is at login.php line 50 is header("location:main.php"); and functions.php looks like:- <?php function checkformat($aUsername) { return TRUE; if(eregi('^[a-z]+[.]+[a-z]+$',$aUsername)) return TRUE; else return FALSE; } function checkmailformat($aEmail) { return TRUE; if(eregi('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+ $',$aEmail)) return TRUE; else return FALSE; }//end function function genpass() { $chars = "1234567890abcdefGHIJKLMNOPQRSTUVWxyzABCDEFghijklmnopqrstuvwXYZ1234567890"; $thepass = ''; for($i=0;$i<7;$i++) { $thepass .= $chars{rand() % 39}; } return $thepass; } ?> and for the life of me I cannot see where "headers already sent by" has occurred. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/124803-solved-misunderstanding-what-is-happening/ Share on other sites More sharing options...
uniflare Posted September 18, 2008 Share Posted September 18, 2008 Is this the entire script? Somewhere above that line is output (maybe a space or a tab). at the start of the script put "ob_start();" before ANYTHING straight after the very first "<?php". Then just before this line (50) put: echo(">>".ob_get_clean()."<<"); Anything in between >><< is being output earlier. You will have to find the output, but also make sure that there are NO gaps between the beginning of the file and the opening php tags, and vice versa the bottom as well. even a \n (newline) is too much for php to handle. (I suggest editing in NotePad++ or similar where you can emit symbols to see stuff like newlines a lot easier.) hope this helps, Quote Link to comment https://forums.phpfreaks.com/topic/124803-solved-misunderstanding-what-is-happening/#findComment-644716 Share on other sites More sharing options...
Zane Posted September 18, 2008 Share Posted September 18, 2008 above that line somewhere you are including this file functions.php that's where the output is. EDIT: my bad I overlooked the functions.php you posted up most likely you are getting an error in functions.php.....that is your output open that file up in a browser separately and see what happens also add this line to the top of it error_reporting(E_ALL|E_STRICT); another note why are you returning the function before you validate it? function checkformat($aUsername) { return TRUE; // if(eregi('^[a-z]+[.]+[a-z]+$',$aUsername)) return TRUE; else return FALSE; } function checkmailformat($aEmail) { return TRUE; if(eregi('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+ $',$aEmail)) return TRUE; else return FALSE; }//end function function genpass() { $chars = "1234567890abcdefGHIJKLMNOPQRSTUVWxyzABCDEFghijklmnopqrstuvwXYZ1234567890"; $thepass = ''; for($i=0;$i { $thepass .= $chars{rand() % 39}; } return $thepass; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/124803-solved-misunderstanding-what-is-happening/#findComment-644729 Share on other sites More sharing options...
uniflare Posted September 18, 2008 Share Posted September 18, 2008 Make sure there is no newline after the end php tag. "output started at /var/www/www.stockton.co.za/doc/pm/functions.php:32" - Line 32 sent output to the browser. Sometimes these error messages can be wrong, it can be further up or further down depending on the situation - but always rule out the most obvious possibilities. Quote Link to comment https://forums.phpfreaks.com/topic/124803-solved-misunderstanding-what-is-happening/#findComment-644737 Share on other sites More sharing options...
stockton Posted September 18, 2008 Author Share Posted September 18, 2008 Thank you. BTW The editor is vim........:-) Quote Link to comment https://forums.phpfreaks.com/topic/124803-solved-misunderstanding-what-is-happening/#findComment-644738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.