Jump to content

Recommended Posts

Here is my problem :  :( Just need solution...

 

In my menu page, i need to fetch one image from database and that file is included in the homepage.

 

menu.php is the included  file, here i have to fetch the image .

 

index.php is the file where menu.php is included, and header file is also included 

 

<tr>

        <td><?php include("includes/menu.php"); ?></td>

      </tr>

 

And when i open it it gives error

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at

 

session is automatically started from config.php file and it is inclued in contact.php page

require_once("config.php");
require_once("user_info.class.php");

 

and when i keep include("config.php"); in menu.php file it gives error.

 

Is there some way where i can keep the config.php file so that it works for all pages... any help

Link to comment
https://forums.phpfreaks.com/topic/71923-warning-session_start-problem/
Share on other sites

Not quite sure I understand what you mean but it sounds similar to a post I answered just recently.  Don't forget that when you put session_start() in an included or required file it will effectively appear in the middle of the original php file and so will break the rule that it must appear before any output.

 

If the first thing in your php file was require_once("config.php") and then session_start() was the first thing in your config.php file then you should be ok.

please read the Header Pinned Post

 

basically you have sent data to the screen before using session_start()

in fact it tells you that the data was sent from in the message "headers already sent (output started at ######"

 

working example

<?php
session_start();
echo "Hi Mom!";
?>

 

Failed example

<?php
echo "Hi Mom!";
session_start();
?>

 

thats that echo could be in an include used before the session_start();

Seems to be a few people that remember to put the session_start() at the beginning of their code but then include that file in some other php file causing the headers already sent message.  It might be worth updating the sticky post to specifically mention this.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.