AdamAsh Posted February 19, 2008 Share Posted February 19, 2008 Hey, I am now to this forum, and very new to the whole web design/PHP so please bear with me. I have read the topic around header errors but still do not understand how to get around this for my problem. I will do my best to explain. I downloaded a free comment script for my (new) site - I have tried to integrate it and get the all too common message: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/vhosts/djadamash.com/httpdocs/contact_me1.php:6) in /var/www/vhosts/djadamash.com/httpdocs/comments/include/session.class.inc.php on line 69 Now I have read about checking for white spaces etc and don't think that is my problem, what my problem I believe, and correct me if I am wrong is that my PHP is in the body of the page as shown here: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/iframe page.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>comments</title> <!-- InstanceEndEditable --> <link href="styles.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> </head> <body> <div id="content"><!-- InstanceBeginEditable name="left" --> <div id="contentLeft"> <p align="center"><img src="images/untitled.JPG" width="118" height="90" /><a href="itpc://djadamash.podOmatic.com/rss2.xml" target="_blank"><img src="http://djadamash.podomatic.com/images/subscribe_with_itunes.gif" width="155" height="44" border="0" align="absbottom" /></a></p> </div> <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="right" --> <div id="contentRight"> <h1>Comment Me</h1> <p>Please leave me a comment below, if you would like to contact me you can so by emailing me on info@djadamash.com - thank you. </p> <?php include("comments/include.php"); ?> </div> <!-- InstanceEndEditable --></div> </body> <!-- InstanceEnd --></html> Moving this to the top of the page works fine, and the comment script works all okay, but I want it to fit into the iFrame like the rest of the site, for continuity, but don't know how to do this, or to get it working right because I now get the error as reported above. I am very new to this so please excuse my ignorance if this is a very simple problem to resolve. My site is www.djadamash.com and the comments section is where the error is present. Please could someone explain to me in simple terms how I can get my comment script into the iFrame and working without this error (if this is at all possible). Thanks for your time. Adam. Quote Link to comment Share on other sites More sharing options...
duclet Posted February 19, 2008 Share Posted February 19, 2008 The error is exactly as it is shown. You have HTML being outputted before the function session_start() is called. This function must be called before anything (even a space) is outputted. You can either move the include up to the very top or if it really needs to be there, you can use output buffering. Add ob_start() at the top and add ob_end_flush() at the end. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 19, 2008 Share Posted February 19, 2008 A call to session_start() must occur before any output is sent to the browser. It would appear that comments/include.php contains a call to session_start(); therefore it has to be at the top of your script, whether you want to put it there or not. Now if comments/include.php creates some output you wish to capture and insert further down in the page, you can do this: <?php ob_start(); include("comments/include.php"); $comments = ob_get_contents(); ob_end_clean(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/iframe page.dwt" codeOutsideHTMLIsLocked="false" --> <head> ... And then where you currently have your include() statement: <?php echo $comments; ?> Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 19, 2008 Author Share Posted February 19, 2008 Thanks for your quick replies. I tried this but still it doesn't add this into the iFrame www.djadamash.com :-\ Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 19, 2008 Author Share Posted February 19, 2008 This is what I have now, is this correct? <?php ob_start(); include("comments/include.php"); $comments = ob_get_contents(); ob_end_clean(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/iframe page.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>comments</title> <!-- InstanceEndEditable --> <link href="styles.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> </head> <body> <div id="content"><!-- InstanceBeginEditable name="left" --> <div id="contentLeft"> <p align="center"><img src="images/untitled.JPG" width="118" height="90" /><a href="itpc://djadamash.podOmatic.com/rss2.xml" target="_blank"><img src="http://djadamash.podomatic.com/images/subscribe_with_itunes.gif" width="155" height="44" border="0" align="absbottom" /></a></p> </div> <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="right" --> <div id="contentRight"> <h1>Comment Me</h1> <p>Please leave me a comment below, if you would like to contact me you can so by emailing me on info@djadamash.com - thank you. </p> <?php echo $comments; ?> </div> <!-- InstanceEndEditable --></div> </body> <!-- InstanceEnd --></html> Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 19, 2008 Share Posted February 19, 2008 I downloaded a free comment script for my (new) site Did it come with instructions? Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 20, 2008 Author Share Posted February 20, 2008 It did but none of them refer to inserting this into an iFrame - as said it works fine without doing that, but I would prefer it to work inside. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 Well what do the instructions say to do? Do they say, "Include() the file and then call a function?" Perhaps it's not enough to include() the file, perhaps after you include it you have to call some_mysterious_comment_function(). We don't know what you downloaded so we can't tell you how to use it. In any case your initial problem is resolved and it sounds like it is now a 3rd party script problem, for which we have a dedicated child board. Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 20, 2008 Author Share Posted February 20, 2008 These are the instructions that came with it: http://www.djadamash.com/comments/docu/docu.html As said I am VERY new to all this so could be that I think I am being a complete n00b and messing up something very simple. Thanks again for taking the time to help. Adam Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 From http://www.djadamash.com/comments/docu/docu.html#_Toc151834613 3. Move the variable $c5t_output from the new include.php file to the place in your existing PHP file where you want the Comment Script content to appear. echo $c5t_output; It is important that you delete the variable $c5t_output from include.php once you have moved $c5t_output to your existing web page. Can you paste the contents of include.php into a reply? Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 20, 2008 Author Share Posted February 20, 2008 This is it <?php /** * GentleSource Comment Script * * © Ralf Stadtaus http://www.gentlesource.com/ */ define('C5T_ROOT', '/var/www/vhosts/djadamash.com/httpdocs/comments/'); include C5T_ROOT . 'comment.php'; #echo $c5t_output; ?> Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 Try changing: #echo $c5t_output; to echo $c5t_output; As long as you still have the changes from earlier in place the contents should go into the buffer and come out on the right place on the page. Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 20, 2008 Author Share Posted February 20, 2008 Same again I think it is just destined not to work. Thanks for your help though, really appreciated Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 And you're not getting any errors or anything? Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 20, 2008 Author Share Posted February 20, 2008 Nothing at all - The page on my site can be seen here: www.djadamash.com and select comments from the header - you can see the comment box is there fine, it just falls outside the iFrame, but I want it inside like the rest of the site Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 Ok. So the comments stuff is showing up. It's just not exactly how you'd like it. My first question is, if the pages shown in the iframe are served from the same site, why do you have an iframe to begin with? If you eliminate the iframe the page will grow to fit it's contents. My second question is, how come you have the height attribute on the iframe set to 480? That would seem to be why the page is only partially displaying the comments box. Try a larger setting, like 650, if you are adamant about keeping the iframe. Quote Link to comment Share on other sites More sharing options...
AdamAsh Posted February 22, 2008 Author Share Posted February 22, 2008 Te iFrame is there because I am setting up an affiliate scheme with a music provider to sell music online, and to do this they will be hosting the framework for the site and I will link to it inside the iFrame. I also had a flash banner which streamed my podcast through it. I will adjust the heigh slightly see if that makes any difference Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.