Cannot add header information 
Author Message
 Cannot add header information

When i run this script:

<?php
require("../dbconnect.php");
$auth = false; // Assume user is not authenticated

if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {

        // Formulate the query
    $sql = "SELECT * FROM users WHERE
            username = '$PHP_AUTH_USER' AND
            password = '$PHP_AUTH_PW'";    

        // Execute the query and put results in $result
    $result = mysql_query( $sql )
        or die ( 'Unable to execute query.' );

        // Get number of rows in $result.
    $num = mysql_numrows( $result );

        if ( $num != 0 ) {
        // A matching row was found - the user is authenticated.
        $auth = true;
    }

Quote:
}

if ( ! $auth ) {
    header( 'WWW-Authenticate: Basic realm="Private"' );
    header( 'HTTP/1.0 401 Unauthorized' );
    include("admin_authorization_required.php");
    exit;

Quote:
}

mysql_close();
?>

I get the following error:

Warning: Cannot add header information - headers already sent by
(output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
/home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 25

Warning: Cannot add header information - headers already sent by
(output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
/home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 26

The strange thing is that i use exactly the same script on other sites
without any errors. On the other sites i get the password dialog box
popup but not on this one, and i don't understand why, therfore the
query isn't even getting looked at.

Thanks for your help...



Fri, 25 Mar 2005 18:56:38 GMT  
 Cannot add header information

Quote:
> When i run this script:

> <?php
> require("../dbconnect.php");
> $auth = false; // Assume user is not authenticated

> if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {

> // Formulate the query
>     $sql = "SELECT * FROM users WHERE
>             username = '$PHP_AUTH_USER' AND
>             password = '$PHP_AUTH_PW'";

> // Execute the query and put results in $result
>     $result = mysql_query( $sql )
>         or die ( 'Unable to execute query.' );

> // Get number of rows in $result.
>     $num = mysql_numrows( $result );

> if ( $num != 0 ) {
>         // A matching row was found - the user is authenticated.
>         $auth = true;
>     }
> }
> if ( ! $auth ) {
>     header( 'WWW-Authenticate: Basic realm="Private"' );
>     header( 'HTTP/1.0 401 Unauthorized' );
>     include("admin_authorization_required.php");
>     exit;
> }

> mysql_close();
> ?>

> I get the following error:

> Warning: Cannot add header information - headers already sent by
> (output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
> /home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 25

> Warning: Cannot add header information - headers already sent by
> (output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
> /home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 26

> The strange thing is that i use exactly the same script on other sites
> without any errors. On the other sites i get the password dialog box
> popup but not on this one, and i don't understand why, therfore the
> query isn't even getting looked at.

> Thanks for your help...

Most likely you have a blank line at the end of dbconnect.php after ?> -
this would be considered output sent to the browser.


Fri, 25 Mar 2005 19:01:47 GMT  
 Cannot add header information
hi,

i think you'r connection to the db fails - which then produces an error
message. So you have already outputtet html and you can't add headers.

mfG
Wolfi

Quote:
> When i run this script:

> <?php
> require("../dbconnect.php");
> $auth = false; // Assume user is not authenticated

> if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {

>    // Formulate the query
>     $sql = "SELECT * FROM users WHERE
>             username = '$PHP_AUTH_USER' AND
>             password = '$PHP_AUTH_PW'";      

>    // Execute the query and put results in $result
>     $result = mysql_query( $sql )
>         or die ( 'Unable to execute query.' );

>    // Get number of rows in $result.
>     $num = mysql_numrows( $result );

>    if ( $num != 0 ) {
>         // A matching row was found - the user is authenticated.
>         $auth = true;
>     }
> }
> if ( ! $auth ) {
>     header( 'WWW-Authenticate: Basic realm="Private"' );
>     header( 'HTTP/1.0 401 Unauthorized' );
>     include("admin_authorization_required.php");
>     exit;
> }

> mysql_close();
> ?>

> I get the following error:

> Warning: Cannot add header information - headers already sent by
> (output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
> /home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 25

> Warning: Cannot add header information - headers already sent by
> (output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
> /home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 26

> The strange thing is that i use exactly the same script on other sites
> without any errors. On the other sites i get the password dialog box
> popup but not on this one, and i don't understand why, therfore the
> query isn't even getting looked at.

> Thanks for your help...



Fri, 25 Mar 2005 19:18:00 GMT  
 Cannot add header information
thanks for your help,

there were two blank lines at the end of dbconnect

sorry but errors like that can be so awkward to find sometimes!


Quote:


> > When i run this script:

> > <?php
> > require("../dbconnect.php");
> > $auth = false; // Assume user is not authenticated

> > if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {

> > // Formulate the query
> >     $sql = "SELECT * FROM users WHERE
> >             username = '$PHP_AUTH_USER' AND
> >             password = '$PHP_AUTH_PW'";

> > // Execute the query and put results in $result
> >     $result = mysql_query( $sql )
> >         or die ( 'Unable to execute query.' );

> > // Get number of rows in $result.
> >     $num = mysql_numrows( $result );

> > if ( $num != 0 ) {
> >         // A matching row was found - the user is authenticated.
> >         $auth = true;
> >     }
> > }
> > if ( ! $auth ) {
> >     header( 'WWW-Authenticate: Basic realm="Private"' );
> >     header( 'HTTP/1.0 401 Unauthorized' );
> >     include("admin_authorization_required.php");
> >     exit;
> > }

> > mysql_close();
> > ?>

> > I get the following error:

> > Warning: Cannot add header information - headers already sent by
> > (output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
> > /home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 25

> > Warning: Cannot add header information - headers already sent by
> > (output started at /home/www/aertiaTh/aprop3/dbconnect.php:11) in
> > /home/www/aertiaTh/aprop3/admin/admin_authenticate_user.php on line 26

> > The strange thing is that i use exactly the same script on other sites
> > without any errors. On the other sites i get the password dialog box
> > popup but not on this one, and i don't understand why, therfore the
> > query isn't even getting looked at.

> > Thanks for your help...

> Most likely you have a blank line at the end of dbconnect.php after ?> -
> this would be considered output sent to the browser.



Sat, 26 Mar 2005 04:55:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Cannot Add Header Information Error

2. ERROR: Cannot modify header information headers already sent by (output started at

3. Cannot modify header information

4. configure error: cannot find a cracklib header file

5. cannot use parameters from subroutine-header when calling Lahey Fortran 90 DLL from Delphi 3

6. TIFF Header Information

7. Excel - File Header Information

8. Information about elf header

9. How to add a header to a file?

10. adding a .gif image in tktable column header cells

11. SB cannot add new method

12. Cannot add a new record under Win95B (CAVO 1.0c)

 

 
Powered by phpBB® Forum Software