memoshop Posted December 17, 2006 Share Posted December 17, 2006 Hi, I am getting a error/warning on the top of my page. It looks like this:[code]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /vservers/shopmemo/htdocs/index.php:2) in /vservers/shopmemo/htdocs/library/config.php on line 11Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /vservers/shopmemo/htdocs/index.php:2) in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]Does anyone have any suggestions on how to fix this problem? Thanks in advance.Nick Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/ Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 session_start() needs to be before ANY output. Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142692 Share on other sites More sharing options...
memoshop Posted December 17, 2006 Author Share Posted December 17, 2006 Hi, thanks for the quick response. However I am kind of new with PHP, can you tell me what that means. Thanks in advance. Here is what the code looks like:[code]<head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?phprequire_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142694 Share on other sites More sharing options...
JP128 Posted December 17, 2006 Share Posted December 17, 2006 [code]<?phpob_start();session_start();?><head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?phprequire_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';ob_end_flush();?>[/code]add those three things... Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142809 Share on other sites More sharing options...
memoshop Posted December 17, 2006 Author Share Posted December 17, 2006 Thanks for you help, however now I am getting a notice.[code]Notice: A session had already been started - ignoring session_start() in /vservers/shopmemo/htdocs/library/config.php on line 11[/code] Here is what the code looks like so far.[code]<?phpob_start();session_start();?><head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?phprequire_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';ob_end_flush();?><table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%"> <tr valign="top"> <td width="164" valign="top" height="100%" background="images/index1_55.jpg" id="leftnav"> <?phprequire_once 'include/leftNav.php';?>[/code]Any suggestions would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142979 Share on other sites More sharing options...
kenrbnsn Posted December 17, 2006 Share Posted December 17, 2006 Move the first four require_once statements to the beginning of your script.[code]<?phprequire_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';?><head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?php$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';ob_end_flush();?><table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%"> <tr valign="top"> <td width="164" valign="top" height="100%" background="images/index1_55.jpg" id="leftnav"> <?phprequire_once 'include/leftNav.php';?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142983 Share on other sites More sharing options...
memoshop Posted December 17, 2006 Author Share Posted December 17, 2006 I made those changes, however I get the warning message again.[code]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]Here is what the full code looks like[code]<?phprequire_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';?><head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?php$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';ob_end_flush();?><table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%"> <tr valign="top"> <td width="164" valign="top" height="100%" background="images/index1_55.jpg" id="leftnav"> <?phprequire_once 'include/leftNav.php';?> </td> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="100%" valign="top"> <p align="center" class="style1"> Current Deals</td> </tr> </table><?phpif ($pdId) { require_once 'include/productDetail.php';} else if ($catId) { require_once 'include/productList.php';} elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return'){ require_once 'include/return_policy.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='shipping'){ require_once 'include/shipping.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_warranties'){ require_once 'include/m_worranties.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='contact_us'){ require_once 'include/contact_us.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return_request'){ require_once 'include/return_request.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='website_issue'){ require_once 'include/website_issue.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='feedback'){ require_once 'include/feedback.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_website'){ require_once 'include/m_website.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='about_us'){ require_once 'include/about_us.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='privacy_policy'){ require_once 'include/privacy_policy.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='aggrement'){ require_once 'include/aggrement.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='search'){ require_once 'include/search.php';}else { require_once 'include/categoryList.php';}?> </td> <td background="images/index1_55.jpg" width="165" align="center" nowrap><?php require_once 'include/miniCart.php'; ?></td> </tr></table><?phprequire_once 'include/footer.php';?>[/code]Any suggestions would be appreciated. Thanks for all the help. Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142986 Share on other sites More sharing options...
kenrbnsn Posted December 17, 2006 Share Posted December 17, 2006 Are you sure there is nothing before the "<?php" in your script. There can't be anything characters there, including blank lines or spaces.Ken Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142988 Share on other sites More sharing options...
paul2463 Posted December 17, 2006 Share Posted December 17, 2006 you still need the session_start() before anything else[code]<?phpsession_start();require_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';?><head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?php$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';ob_end_flush();?><table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%"> <tr valign="top"> <td width="164" valign="top" height="100%" background="images/index1_55.jpg" id="leftnav"> <?phprequire_once 'include/leftNav.php';?> </td> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="100%" valign="top"> <p align="center" class="style1"> Current Deals</td> </tr> </table><?phpif ($pdId) { require_once 'include/productDetail.php';} else if ($catId) { require_once 'include/productList.php';} elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return'){ require_once 'include/return_policy.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='shipping'){ require_once 'include/shipping.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_warranties'){ require_once 'include/m_worranties.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='contact_us'){ require_once 'include/contact_us.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return_request'){ require_once 'include/return_request.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='website_issue'){ require_once 'include/website_issue.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='feedback'){ require_once 'include/feedback.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_website'){ require_once 'include/m_website.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='about_us'){ require_once 'include/about_us.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='privacy_policy'){ require_once 'include/privacy_policy.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='aggrement'){ require_once 'include/aggrement.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='search'){ require_once 'include/search.php';}else { require_once 'include/categoryList.php';}?> </td> <td background="images/index1_55.jpg" width="165" align="center" nowrap><?php require_once 'include/miniCart.php'; ?></td> </tr></table><?phprequire_once 'include/footer.php';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142989 Share on other sites More sharing options...
kenrbnsn Posted December 17, 2006 Share Posted December 17, 2006 No, the session_start() function is inside the config.php included file. That is obvious from the error the OP posted earlier:[quote]Notice: A session had already been started - ignoring session_start() in /vservers/shopmemo/htdocs/library/config.php on line 11[/quote]Ken Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142991 Share on other sites More sharing options...
memoshop Posted December 17, 2006 Author Share Posted December 17, 2006 I checked and there is nothing before the <?php. So I don't need the session_start() after the <?php? I took that out and I get the previous error again. [code]Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /vservers/shopmemo/htdocs/index.php:1) in /vservers/shopmemo/htdocs/library/config.php on line 11[/code]Here is what the code looks like on my end. [code]<?phprequire_once 'library/config.php';require_once 'library/category-functions.php';require_once 'library/product-functions.php';require_once 'library/cart-functions.php';?><head><style type="text/css">.style1 { font-family: "Bauhaus 93";}.style4 { font-size: xx-large;}</style></head><?php$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;require_once 'include/header.php';ob_end_flush();?><table width="780" border="0" align="center" cellpadding="0" cellspacing="0" height="100%"> <tr valign="top"> <td width="164" valign="top" height="100%" background="images/index1_55.jpg" id="leftnav"> <?phprequire_once 'include/leftNav.php';?> </td> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="100%" valign="top"> <p align="center" class="style1"> Current Deals</td> </tr> </table><?phpif ($pdId) { require_once 'include/productDetail.php';} else if ($catId) { require_once 'include/productList.php';} elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return'){ require_once 'include/return_policy.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='shipping'){ require_once 'include/shipping.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_warranties'){ require_once 'include/m_worranties.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='contact_us'){ require_once 'include/contact_us.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='return_request'){ require_once 'include/return_request.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='website_issue'){ require_once 'include/website_issue.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='feedback'){ require_once 'include/feedback.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='m_website'){ require_once 'include/m_website.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='about_us'){ require_once 'include/about_us.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='privacy_policy'){ require_once 'include/privacy_policy.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='aggrement'){ require_once 'include/aggrement.php';}elseif(isset($_REQUEST['action']) && $_REQUEST['action']=='search'){ require_once 'include/search.php';}else { require_once 'include/categoryList.php';}?> </td> <td background="images/index1_55.jpg" width="165" align="center" nowrap><?php require_once 'include/miniCart.php'; ?></td> </tr></table><?phprequire_once 'include/footer.php';?>[/code]Thanks again for all the help. Any suggestions would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/30927-getting-errorwarning/#findComment-142995 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.