Legend of the Green Dragon
Go Back   LotGD.net Forum > Gameplay > Newbie Player Forum - What is this about? How do I do something?
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 03-30-2004, 03:51 PM
MightyE's Avatar
MightyE MightyE is offline
Creator
Carrot
 
Join Date: Aug 2003
Posts: 452
MightyE has disabled reputation
Default Headers Already Sent Errors

If you're getting an error that looks like this:
Code:
Warning: session_register(): Cannot send session cookie - headers already sent by (output started at /home/yoursite/public_html/dbconnect.php:12) in /home/yoursite/public_html/common.php on line 1496
This means that somewhere, somehow, your PHP code is sending output to the browser before the session is started. Yeah, I know, technical mumbo jumbo. What do I do to fix it?

The warning you get gives you the information required to locate where the problem is. Let's disect the error:
Code:
Warning: session_register(): Cannot send session cookie - headers already sent by
This part tells you what kind of warning it is. In this case, the HTTP headers have already been sent to the browser. HTTP headers are sent to the browser once the first output is encountered in the script.
Code:
(output started at /home/yoursite/public_html/dbconnect.php:12)
This is the part we're most interested in. It tells us first, that the problem is in the file found at "/home/yoursite/public_html/dbconnect.php" and second that it is at line 12 (note the :12 at the end). This is where we need to look to find the problem.

So edit the file mentioned (in this case, dbconnect.php) and find the appropriate line (in this case 12). See what's going on there that might be causing data to be sent out to the browser. Remember, anything that is found OUTSIDE of the <? and ?> tags in PHP is seen as output.

The MOST common problem here is blank lines at the end of the dbconnect.php file, after the ?> mark. Some text editors will add these lines, which can be a big problem. Use Notepad instead of Word Pad to edit the file. Make sure that there's no blank lines after the ?> mark, and chances are your problems will go away.

Also, you might see problems here if you use echo or print to send data to the browser, such as
Code:
echo "Connected to the database
";
within your dbconnect.php file will cause PHP to whine when it tries to start the session later on.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Premature End Of Script Headers Error thinksmart Newbie Player Forum - What is this about? How do I do something? 5 09-28-2005 05:35 AM
PHP errors in the forest jshall Newbie Player Forum - What is this about? How do I do something? 3 09-26-2005 09:30 AM
Setup errors ShadowDemon342 Newbie Player Forum - What is this about? How do I do something? 1 09-22-2005 06:22 PM
LoGD Net errors Bellwether Newbie Player Forum - What is this about? How do I do something? 4 08-11-2004 10:03 AM
Warning: Cannot modify header information - headers already don1zer Newbie Player Forum - What is this about? How do I do something? 2 02-06-2004 10:10 AM


All times are GMT -5. The time now is 06:32 PM.


LotGD skin design by Ben 'blarg' Wong
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.