The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Tip to Cure: Warning: Cannot add header information - headers already sent by Error
This is one of the most frequent errors you can get especially when you are hacking vb. It's easy to fix for someone who knows what he is doing, can be very hard to trace for others. If you are getting this error, I can not fix it for you, but some tips as to why this error happens can give you the ground to fix it yourself. Why the Error happens? First here is a technical background: Before the server sends a HTML info to the user, it first performs some special actions and sends a "header" page before it starts posting HTML elements of this page. These special actions and header information can not be send AFTER you started to send the HTML elements to user's browser. For example, one of the most commonly used of these special actions is setting a cookie in user's computer. Cookie setting should be done inside the "header" and header should be sent before anything else is sent. So you can not set a cookie in user's computer say in the middle of a HTML page. If you try, you'll get this infamous error message: "Warning: Cannot add header information - headers already sent by.." So the reason this error happens is your script started sending some HTML output and after that it tried to send an "header" which is wrong. The error in vbulletin Hacking: While you hack vb, you can encounter this problem if you wrongly hacked some vb files (eg. functions.php, config.php, global.php) which runs before HTML output begins. If you accidently started the HTML output in these files, you'll end up with this error. This is because after these files run, vbulletin tries to make some "header" related actions like checking user's cookie or attempting to set a cookie for the user and if you started the HTML output accidently beforehand, header can not be formed and this error happens. This error is easy to fix if you know where you hacked and what causes this error. Just look for the additions you made in the code and try to find which part of it sends an information to user's browser and remove it. But if you are a newbie this can be hard to trace because unlike what you think, the displayed information that causes this error is not always very easy to see. This information can be anything, even some invisible elements. For example "new line" command or even a "space" character (both of which are invisible to you) causes this error. For example: functions.php or config.php file ends with the line: PHP Code:
PHP Code:
How to read the the error message you get: When you receive this error, you'll get a message like this: Quote:
How the fix it: Needless to say, you have to remove unnecessary line/section that starts the unauthorized HTML output. You have to be careful as this can be an invisible character like a space or new line as mentioned above. If the output line that produces the error is very small like 1, 2 or 3, you make sure there is nothing else before <?php at the begining of the file. If the line number is too big then make sure you check there is nothing after ?> at the end of file. If the line is in the middle look for a "echo" command there, it may be the cause. These are just frequent occurences of this eror but do not cover all issues regarding this error, so you have to remember the general rule to fix it in your script: Remove any char. that starts the HTML output in the part error mentions. If you are not very skilled at PHP, have no tools (sophisticated text/HTML editing tools like editplus) that show you invisible chars or can't find the error no matter what then your best bet is to remove the last hack you installed and reinstall it if necessary but this time more carefully. If you are desperate you can replace the file that produces the error with an unhacked vb file which will help you get rid of the error instantly. (Be warned, you'll lose all hacks you applied to this file). Good luck! :glasses: |
#2
|
||||
|
||||
Good text pal
but i think Hacking Hints and Tips would be the better place for it *move* |
#3
|
||||
|
||||
Nice Stuff!
|
#4
|
||||
|
||||
This also happens if you try to echo out from within the files before the headers are sent
|
#5
|
||||
|
||||
Thanks, this kind of info is very much appreciated and valued
|
#6
|
||||
|
||||
Took me a while to figure this one out on my own.
|
#7
|
||||
|
||||
Output Buffering
Use output buffering with ob_start() and ob_end_flush(). Although ob_end_flush() isn't needed in MOST cases because it is called automatically at the end of script execution by PHP itself when output buffering is turned on either in the php.ini or by calling ob_start() PHP Code:
|
#8
|
||||
|
||||
Quote:
|
#9
|
|||
|
|||
gotten the same type of error when doing a quick edit on a php file using Cpanel's file edit.
It added a blank line at the end of the file. Once I found that (took a few minutes), the error went away. |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|