Include And Require Files In Php

I get header already sent errors when I try to include an exteranl php fuile in my main php file. This does not happen on my home server just when I upload to my NEw account at TCH. Does anybody know what I need to do to fix this issue?<!--content-->
Welcome! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />This probably belongs in a different forum, but I think I can help anyway.<br /><br />It sounds as if you are trying to send a header after some output has already been sent to the page. If I am mistaken, please correct me.<br /><br />Usually this happens when there is an extra line in the include file that just happened to show up during the transfer or edit. It's a weird thing, but it happens to me all the time. <br /><br />Check the bottom of your include file to make sure there are no extra lines after the PHP close tag "?>" at the bottom of your include file. None, nada, zip. Otherwise a blank line is being included.<br /><br />For some reason, Cpanel File Manager loves to add an extra line or two when I edit my files. Other software may do it too, for all I know.<br /><br />If you PM me your URL, I can take a look if you like.<br /><br />HTH,<br />Dave<!--content-->
How are you linking to the file?<br /><br />like this ?<br /><br />include $_SERVER['DOCUMENT_ROOT']."/path/to/file.php";<br /><br /><br /><br /><br /><br /><br />moving for better forum organization.<!--content-->
I had the same problem with TCH without using include or require. My fix was to add <br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->php_value display_errors 1<!--c2--></div><!--ec2--><br />to the end of the .htaccess in the folder of the offending script. It can be a fairly common error in PHP with many server setups <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br /><br />EDIT: BTW I was not setting ANY hedder information in the offending script. I am not " ignoring the error may correct it on-screen"<!--content-->
Welcome to the family, David <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />About the script, can you paste some code here, so we can take a look at it? Remember to strip out sensitive information.<!--content-->
It seems that you're sending HTTP header information (for instance, a content-type declaration) after you've already output some data. I had a similar problem with some of my scripts. While ignoring the error may correct it on-screen, it may also prevent the header from being sent, which may cause other problems. Check your PHP and make sure that you are sending HTTP headers _only_ before you send any other information at all. If that isn't clear, post some of your code here so we can see what sort of problem you're having.<!--content-->
 
Back
Top