Headers already sent by...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
techlinks
Forum Newbie
Posts: 18
Joined: Sun Dec 29, 2002 4:00 am

Headers already sent by...

Post by techlinks »

Hi:

I'm using a popular MySQL class named "PHPTOOLS4U" for a project I'm working on. Its found at:

http://www.phptools4u.com/scripts/shows ... ript=mysql

Whenever I simply include the class, any code I have that calls the header() function fails with:

Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\lib\mysql_inc.php:197

The strange thing is that I'm not even calling any functions; just including it. If you took a quick peek at the source at:

http://www.phptools4u.com/scripts/shows ... ript=mysql

...is there anything obvious you see that suggests that the mere inclusion of this class causes PHP to think that header information has already been sent? I just can't see it so I'm hoping a another pair of eyes can help. It's a fairly short class library, say about 6 functions only.

Thanks for your help.

Techlinks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

double check that there's nothing before <?php and nothing after ?>
Not a linebreak nor a space, nothing
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

you can always start your page with:

<?php

ob_start()

?>

and at the end put

<?php

ob_end_flush()

?>

That way you can define your headers anywhere inside the document.
Post Reply