illdevilinc 0 Report post Posted March 9, 2006 Hi im using my page in php coding and the session_start() code is messing something up. This is the error:Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/idimm/public_html/index.html:2) in /home/idimm/public_html/index.html on line 103Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/idimm/public_html/index.html:2) in /home/idimm/public_html/index.html on line 103:Does anyone know how to fix this? It does do the command but it gives this annoying error message no madder what. Please help i would like to get this feature working on my site. This is being a very hard code. Stupid PHP. But heres the url for the site if you want to go to it and see the error your self. The error page. thanks,me Share this post Link to post Share on other sites
Hat 0 Report post Posted March 9, 2006 index.html has to be changed to .php for one thing...and thats I'm all I'm good for, because I suck at PHP. Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted March 9, 2006 Well there is a problem right at the top of your page which needs to be sorted out before you get any further along. There are some things way out of place and missing. The typical sequence for an html (or htm) page should be something like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/;'>http://forums.xisto.com/no_longer_exists/; <html xml:lang="en" lang="en" xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="content-type" content="text/html; charset=iso-8859-1" /><link rel="shortcut icon" href="favicon.ico" /><link href="something.css" rel="stylesheet" type="text/css" media="all"> <title>Demo title</title> <style type="text/css" media="screen"><!-- Insert the embedded styles here --> </style><script type="text/javascript">onload = function() { content.focus() }</script></head> <body><!-- Main Html Code for the page --></body></html> I did a view source of the Xisto page to snag some of this, so it might not be exactly what you want, but the order of the tags is what I was attempting to show you. The Doc Types must be exactly coded or they will blow up pretty quickly. Now do a view > source of your page and compare the two. You don't have a Doc Type, the first tag is a style tag, there are several other things there to fix up before you get to the Header problem. After you have fixed these things as best as you can, run the page through the w3c Validator at their site, http://www.w3.org/, to make sure it passes. The validation won't check logic or php errors, but it will tell you if all is well with the syntax of the page. As for the Headers, see the php manual at http://ca.php.net/manual/en/function.header.php. There are also rules about how to send the Cookies used for the sessions. setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie. Share this post Link to post Share on other sites
illdevilinc 0 Report post Posted March 9, 2006 (edited) index.html has to be changed to .php for one thing...and thats I'm all I'm good for, because I suck at PHP. I am using a .htaccess file so i dont need to change the type of page. Well there is a problem right at the top of your page which needs to be sorted out before you get any further along. There are some things way out of place and missing. The typical sequence for an html (or htm) page should be something like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/;'>http://forums.xisto.com/no_longer_exists/; <html xml:lang="en" lang="en" xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="content-type" content="text/html; charset=iso-8859-1" /><link rel="shortcut icon" href="favicon.ico" /><link href="something.css" rel="stylesheet" type="text/css" media="all"> <title>Demo title</title> <style type="text/css" media="screen"><!-- Insert the embedded styles here --> </style><script type="text/javascript">onload = function() { content.focus() }</script></head> <body><!-- Main Html Code for the page --></body></html> I did a view source of the Xisto page to snag some of this, so it might not be exactly what you want, but the order of the tags is what I was attempting to show you. The Doc Types must be exactly coded or they will blow up pretty quickly. Now do a view > source of your page and compare the two. You don't have a Doc Type, the first tag is a style tag, there are several other things there to fix up before you get to the Header problem. After you have fixed these things as best as you can, run the page through the w3c Validator at their site, http://www.w3.org/, to make sure it passes. The validation won't check logic or php errors, but it will tell you if all is well with the syntax of the page. As for the Headers, see the php manual at http://ca.php.net/manual/en/function.header.php. There are also rules about how to send the Headers. The page was generated by Microsoft Frontpage 2003. The headers were automaticly generated by frontpage and the code has been checked by it. Im not sure if this is the problem because the problem is that i am putting the php code in a TABLE and it requires a seesion_start() which i have just found out that it must be on the top of the page to function properly. If i put the whole code up on the top it works fine but if it is in the table i get a error. I have no idea how to get it to work in the tables but i am experimenting with it and everything so far has failed. If anyone has any information on how to put this kind of code in a table please help me.here is the code <?phpsession_start();//check to see if the user already has an open sessionif (($_SESSION[user_name] != "") && ($_SESSION[password] != "")){ echo"Favorites--Logout";}else echo"Login";?>and here is the code for the shared border that this code is in <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Shared Top Border</title><meta name="GENERATOR" content="Microsoft FrontPage 6.0"><meta name="ProgId" content="FrontPage.Editor.Document"><meta name="Microsoft Theme" content="none"><meta name="Microsoft Border" content="none"></head><body><p align="left"><font color="#808080" size="2"><br></font><font color="#FFFF00">We Now support<script type="text/javascript"><!--google_ad_client = "pub-7806936936690646";google_ad_width = 180;google_ad_height = 60;google_ad_format = "180x60_as_rimg";google_cpa_choice = "CAAQ24Oy0QEaCGbgW7AaXRokKMu293M";//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><br></font><font size="2"><!--webbot bot="Navigation" s-type="top" s-orientation="horizontal" s-rendering="graphics" b-include-home="TRUE" b-include-up="TRUE" s-theme="classic 0010" --></font></p><div style="position: absolute; width: 100px; height: 100px; z-index: 16; left: 740px; top: 16px" id="layer21"> <p align="center"><!--webbot bot="HTMLMarkup" startspan --><form target="paypal" action="https://https://www.paypal.com/home; method="post"><input type="hidden" name="cmd" value="_cart"><input type="hidden" name="business" value="illdevilinc@gmail.com"><input type="image" src="https://http://forums.xisto.com/no_longer_exists/;'>http://forums.xisto.com/no_longer_exists/; border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"><input type="hidden" name="display" value="1"></form><!--webbot bot="HTMLMarkup" endspan --></div><p align="center"><font size="2"><img border="0" src="../images/IDI%20METAL%20MUSIC%20LOGO.JPG" width="84" height="65" alt="Metal Music" align="left"></font></p><div style="position: absolute; width: 505px; height: 62px; z-index: 10; left: 181px; top: 233px" id="layer14"> <p align="center">Advertisement<font size="1">▼</font> <script type="text/javascript"><!--google_ad_client = "pub-7806936936690646";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel ="";google_color_border = "333333";google_color_bg = "000000";google_color_link = "FFFFFF";google_color_url = "999999";google_color_text = "CCCCCC";//--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><p align="center"> </p><table border="1" width="100%" id="table2"> <tr> <td><?phpsession_start();//check to see if the user already has an open sessionif (($_SESSION[user_name] != "") && ($_SESSION[password] != "")){ echo"Favorites--Logout";}else echo"Login";?></td> <td> </td> <td> </td> </tr></table><div style="position: absolute; width: 510px; height: 100px; z-index: 17; left: 181px; top: 327px" id="layer22"> <p align="center">Need to find something? Then search our site! (Provided by Google)<br> <!--webbot bot="HTMLMarkup" startspan --><!-- SiteSearch Google --> </p><form method="get" action="https://www.google.com/custom&%2334; target="google_window"> <table border="0" bgcolor="#000000"> <tr> <td nowrap="nowrap" valign="top" align="left" height="32"> <p align="right"></td> <td nowrap="nowrap" align="center"> <input type="hidden" name="domains" value="metalmusic.trap17.com"> <p align="right"> <input type="text" name="q" size="10" maxlength="255" value> <input type="submit" name="sa" value="Google Search"> </td> </tr> <tr> <td> <p align="right"> </td> <td nowrap="nowrap" align="center"> <table> <tr> <td> <p align="right"> <input type="radio" name="sitesearch" value checked="checked"> <font size="-1" color="#ffffff">Web</font> </td> <td> <p align="right"> <input type="radio" name="sitesearch" value="metalmusic.trap17.com"> <font size="-1" color="#ffffff">metalmusic.trap17.com</font> </td> </tr> </table> <input type="hidden" name="client" value="pub-#############"> <p align="right"><input type="hidden" name="forid" value="1"> <input type="hidden" name="ie" value="##########"> <input type="hidden" name="oe" value="################"> <input type="hidden" name="safe" value="active"> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;"> <input type="hidden" name="hl" value="en"></td> </tr> </table></form><p><!-- SiteSearch Google --></p><!--webbot bot="HTMLMarkup" endspan --></div><p align="center"> </p></body></html>thank you for the people that are willing to help me Edited March 9, 2006 by illdevilinc (see edit history) Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted March 9, 2006 Quoted from the php manual $session_start(): NOTE: If you are using cookie-based sessions, you must call session_start() before anything is output to the browser.Sorry, I mistakenly referenced to the $set_cookies (). So, yes, having the #session_start() in the middle of the tablet, after output has started to the browser will throw an error. Share this post Link to post Share on other sites
OpaQue 15 Report post Posted March 9, 2006 Check all your INCLUDE / REQUIRE files and see if there is any space left after ?> OR Before <? Share this post Link to post Share on other sites
illdevilinc 0 Report post Posted March 10, 2006 I have tried callin session_start() before the html coding but i cant have my loogin/logout coding at the top. I am trying to keep them in the table that i have created for them but im not sure how to do it. I have tried caling session start like this:<?Session_start()?>HTML CODE <? LOGIN SCRIPT CODE?> But it did not give an error but didnt work. If anyone knows something i could do to call the session before the html but still have the actual login/logout script in the table please tell it to me.Im sorry i wasnt clear of my problem.And thanks for trying to help me! Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted March 10, 2006 Post the code for the entire page including the Login Script, please. Doing a view source doesn't show the php script or form handling. Might be something there. Share this post Link to post Share on other sites
moldboy 0 Report post Posted March 10, 2006 You say you want the login in the table with the form. That makes sense, it's the natural way to program, and when I first started php the lack of a goto function drove me crazy. The reason the model you have tried (but can't get to wirk) isn't returning an error is because you set the page up properly. Session_start() must be the first line sent to the browser, so fir example in the following code (I just wrote this there may be errors) <html><head></head><body><?phpif $sessions == TRUE{session_start();};else {echo "<p>session were not requested</p>";};?></body></html>this code will result in an if session == TRUE because it will try to start the session after the browser has recieved code (the <html>... stuff)Umm, you really need to post a little more code, If you use session_start() at the top of the page so it doesn't return an error, then you should be able to set session variables at any point later in the page. It may very well be the way you are calling the variables that results in it not working.That's all I can think of right now, without more code, I'm sorry I can't be of more help Share this post Link to post Share on other sites