Not sure if this is in the right place, sorry if not.

I recently installed an image rating software to my site, and I've nearly got it up and running, after configuring the config.php, creating the databases, but I'm running into a couple of problems.

When i go to the front-end of the Image Rater, I can see and use all of the functions, but I have this error message at the top of the screen:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pseud/public_html/pictures/irater/admin/config.php:72) in /home/pseud/public_html/pictures/irater/include/session.php on line 75

When I go to the back-end of the image rater, to administrate and alter settings etc, I see nothing but these two error messages:

admin: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pseud/public_html/pictures/irater/admin/config.php:72) in /home/pseud/public_html/pictures/irater/include/session.php on line 75

Warning: Cannot modify header information - headers already sent by (output started at /home/pseud/public_html/pictures/irater/admin/config.php:72) in /home/pseud/public_html/pictures/irater/admin/index.php on line 10

I know next to zero php coding, just the real basic stuff like how to configure and create a database to get php software/scripts installed.

can anyone help (in lament terms) with how I could go about fixing this?

Thanks for your time,
Andy

    OK at the top of your php script put

    ob_start();
    

    and at the very bottom put

    ob_end_flush();
    

    HTH

    GM

      ok, before i do that, it may seem like a stupid question but do you mean the index.php script in the irater dir, or the admin dir.. or something else?

        I mean at the beginning of the top php script that is used

        e.g index.php has "include scripts.php" at the top of it and "include "footer.php" at the bottom

        So put the ob_start() at the top of scripts.php and ob_end_flush() at the bottom of the footer.php

        GM

          <?
          
          include("./admin/config.php");
          include("$include_path/functions.php");
          include("$include_path/session.php");
          include("$include_path/common.php");
          
          (snipped the middle out to reduce size)
          
          
          include("$include_path/stats.php");
          
          $final_output .= <<<FO
          </td>
          </tr>
          FO;
          
          }
          
          $final_output .= <<<FO
          </table>
          </td>
          </tr>
          </table>
          </body>
          </html>
          FO;
          
          echo $final_output;
          
          ?>
          

          That's the top part of the index.php

          I put the ob_start at the very top of the config.php in the admin folder, and then the ob_end at the very bottom of the stats.php... right?

          heh, sorry if i'm being dumb, i just dont wanna fuck things up...

            You are right to put the start at the top of the admin script but put the ob_end_flush ater the echo statement

            GM

              Ahhh, i see how that works.. so the ob_end command is the very last thing it does.

              And, you, are a legend, cuz you just got it working. Thank you SO much for your help. Anything I can do for you?

                Let me explain how it works

                at the top you have ob_start() then everything between that and ob_end_flush is stored in a buffer. The advantage of putting stuff in a buffer is that you can put header(....) wherever you want without having the problems of "headers already sent ...." then when you do ob_end_flush the complete contents of the buffer are send to the browser.

                Take a look at the php.net site about ob_start()

                HTH

                GM

                Hmm you could tell me next weeks winning lottery numbers - that'd be payment enough 😃

                  Can you believe I actually paid good money for that script? I was starting to wonder wether I'd installed it correctly.

                  Anyway, here's the numbers:

                  4, 16, 17, 22, 33, 47

                  But, if you use them, you'll be splitting the jackpot with me :p

                    Fine then but you have to come to the UK to collect your half of the money

                    GM

                      Oh man, you KNOW you've been talking to americans online for too long when fellow brits start mistaking you for one! lol

                      Berkshire Born and Berkshire Bred mate

                        11 days later

                        I'm kinda having the same problem, but my page seems to take an age to output anything. I have done exactly what people have said, i.e. having the ob_start() right at the top and ob_end_flush() right at the bottom. However (as I said before) the output doesn't appear. Anyone got any ideas?

                          Hi, this is my first post here! I dunno why I've not joined sooner, it's a great community here.

                          As for your problem, I'm curious. Buffering shouldn't have such a delay, the output is only temporarily stored in memory. But it's only released once the PHP script is competed. Does your script have a large time-intensive loop?

                          If it's only because of adding those 2 functions in the script, try removing them, and making sure nothing is output to the browser before the header() and session() functions are called.

                          Garth Farley

                            Originally by piersk
                            I'm kinda having the same problem, but my page seems to take an age to output anything.

                            I'm not sure about that one; of course, using output buffering as an alternative to rewriting your code so that it doesn't send any output before trying to send headers means that nothing will be sent from the page until processing reaches that ob_end_flush(). So there's a delay right there. And of course all that generated HTML is being buffered, so it's taking memory, which needs to be allocated - and reallocated - as needed, and of course it may not be the only script running at the time, and the others might be buffering output themselves. Those would all be performance hits.

                            One speedup would be to move the flush up as far as possible (as close to immediately after the last header call as can be managed, basically). But I still prefer the "do the headers first" approach whenever feasible. Slapping ob_*() functions around everything is a bit of a no-think copout.

                              Spose. I reckon I'm gonna have to rewrite it anyway. ta for your help.

                                Weedpacket - I do agree with you that ob is not the best option for coding - however when it comes to legacy code if its a case of "hacking apart X hundred lines of code" or using OB i know my preference 😃

                                GM

                                  Well, yeah; after paying money for something you'd expect it to work though, wouldn't you? Like having all the (new, no doubt) session code snapped out into a separate include to go at the top, and the outputting stuff in another include to go where it goes now? I admit I don't know anything 'bout the architecture here.

                                    Hi,

                                    in this case the warnings might come because there might be an empty line or something else outside the php block in config.php file. Make sure that there are no spaces or empty lines outside the php block in config.php.

                                    Just a suggestion ... check if line 72 in config.php is php code or an empty line.

                                    Thomas

                                      Write a Reply...