Jump to content

Recommended Posts

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.

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,

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;
    }
?>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.