claire Posted June 19, 2007 Share Posted June 19, 2007 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/minipla/public_html/cart.php:2) in /home/minipla/public_html/cart.php on line 8 could some one help me with this please....its coming from my cart page. ??? Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 20, 2007 Share Posted June 20, 2007 Usually if you get a "headers already sent error message," you need to add output buffering; it must be the very first thing on page, like below: <?php ob_start(); // Start output buffering ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> and, I think you also need to add this at the end of the page: ob_end_flush(); Hopefully someone who's experienced will come along to clarify or offer other suggestions. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 see the pined topic above Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 20, 2007 Share Posted June 20, 2007 ob_start() will work but really should sort the problam out. session_start() <<< always at top off page and there should never be any html before it. sometimes white spaces cause a problam make sure there are none <?php session_start(); echo hi; ?> << no white spaces becouse the end <? is the last written statement. <?php session_start(); echo hi; ?> << a white spaces becouse the end <? is not last written statement. Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 20, 2007 Share Posted June 20, 2007 Also, another possibility for your specific error (just found the info in some older phpfreak info) is to make sure that <?php session start(): comes before anything else. i.e., <?php session_start(); echo "Blah, blah..."; ?> and not <?php echo "Blah, blah..."; session_start(); ?> Quote Link to comment Share on other sites More sharing options...
claire Posted June 20, 2007 Author Share Posted June 20, 2007 thank you for your time this is the page.....maybe you can see somthing i cant. <?php //call the session id session_id(); //check if session already started. Start if not if (!isset ($_SESSION)) session_start(); //connect to the database require_once('connection1.php'); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Home</title> <link href="main.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!--use to move the whole content--> body { margin-top: 0px; margin-bottom:20px; } #box2 #prodlist .proddiv { } .style1 {color: #000000} .style3 {color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; } .style5 {font-family: Geneva, Arial, Helvetica, sans-serif} .style6 {font-family: Verdana, Arial, Helvetica, sans-serif} a { color: #666666; } .style7 {color: #333333} </style> </head> <body><!--start main div - this centers content on the page--> <div id="main"> <!--start header - contains company logo--> <div id="header"></div> <!--end header--> <!--START NAV--> <p class="home-button"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="65" height="17" title="link to home"> <param name="movie" value="text2.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#688481" /> <embed src="text2.swf" width="65" height="17" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#688481"></embed> </object> <span class="products-button"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="101" height="17" title="link to products"> <param name="movie" value="text3.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#688481" /> <embed src="text3.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="101" height="17" bgcolor="#688481"></embed> </object> </span><span class="training-button"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="88" height="19" title="link to training page"> <param name="movie" value="text6.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#688481" /> <embed src="text6.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="88" height="19" bgcolor="#688481"></embed> </object> </span><span class="faq-button"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="47" height="18" title="link to faq"> <param name="movie" value="text4.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#688481" /> <embed src="text4.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="47" height="18" bgcolor="#688481"></embed> </object> </span> <!--start of customer log in--> <span class="faq-button"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="169" height="19" title="customer log in page"> <param name="movie" value="cutomer.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#688481" /> <embed src="cutomer.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="169" height="19" bgcolor="#688481"></embed> </object> <!--end of customer log in--> </span></p> <?php /* assign the actual session id value to a variable. You are going to use the value in a query below to bring back the correct records from the carttemp table in the database */ $sessid = session_id(); //decare the variable 'total'. The value of this will change as items are added to the cart $total=0; //return all items for this session id from the carttemp table $query = "SELECT * FROM carttemp WHERE sess = '$sessid'"; $results = @mysql_query($query) or die (mysql_query()); //display number of products in cart $rows = mysql_num_rows($results); echo "You currently have " .$rows. " product(s) in your cart. <br />"; ?> </tr> <tr> <br /> <br /> <?php /* display each item from the carttemp table, by using the product id for each record in the carttemp table to query the products table. Reminder: the extract() function accesses the fields in an array and enables you to refer to the field names (table column names) as variables, without ever having declared the variables previously */ while ($row = mysql_fetch_array($results)) { extract ($row); $prod = "SELECT * FROM products WHERE prodnum = '$prodnum'"; $prod2 = mysql_query($prod); $prod3 = mysql_fetch_array($prod2); extract ($prod3); /* declare a form with hidden variables needed to be passed when a user elects to change the quantity of an item */ echo "<td>"; echo "<a href = \"getprod.php?prodid=" . $prodnum . "\">"; //echo "<img src= \"getprod.php?prodid=" . // $prodnum. "\">"; echo "<img src=\"teeshirts/$img_tmb\" width=\"$t_w\" height=\"$t_l\"/><br />IMAGE</a></td>\n"; echo "</a></td>\n"; echo "<td>"; echo "<a href = \"getprod.php?prodid=" . $prodnum . "\">"; echo $name; echo "</a></td>\n"; echo "<td class=\"right\">"; echo $price; echo "</td>\n"; echo "<td class=\"right\">"; //get extended price $subtotal = $price * $quan; //this adds commas to the number displayed. e.g. 1,000.00 $extprice = number_format ($subtotal, 2); echo $extprice; echo "</td>\n"; //CHANGE echo "<td><form method =\"post\" action=\"change.php\"> <input type=\"hidden\" name=\"prodnum\" value=\"$prodnum\"> <input type=\"hidden\" name=\"sessid\" value=\"$sessid\"> <input type=\"hidden\" name=\"temp_id\" value=\"$temp_id\"> <br /> <input type=\"text\" name=\"qty\" size=\"2\" value=\"$quan\">"; echo "</td>\n"; echo "<td>"; echo "<input type=\"submit\" name=\"Submit\" value=\"Change Qty\"> </form></td>\n"; echo "<td>"; /* declare a form with hidden variables needed to be passed when a user elects to delete an item from the cart ..............DELETE */ echo "<form method = \"post\" action=\"delete.php\"> <input type=\"hidden\" name=\"prodnum\" value=\"$prodnum\"> <input type=\"hidden\" name=\"qty\" value=\"$quan\"> <input type=\"hidden\" name=\"temp_id\" value=\"$temp_id\"> <input type=\"hidden\" name=\"sessid\" value=\"$sessid\">"; echo "<input type=\"submit\" name=\"Submit\" value=\"Delete Item\"> </form></td>\n"; echo "</tr>\n\n"; /* remember that this is a while loop so the next line will change with each iteration of the loop. When $total is printed to the screen below it will have reached a value equal to the sum of all items */ $total = $subtotal + $total; } ?> <br /> <br /> <tr> <br /> <br /> <td><a href="checkout.php"><img src="cart_pic.jpg" alt="cart" width="72" height="74" /></a></td> <br /> <td colspan="4" class="right">Your total before shopping is:</td> <td class="right"><?php echo number_format ($total,2) ?></td> <td> </td> <td> </td> </tr> </table> <div align="left"> <br /> <?php /* The next section deals with what happens when the user clicks "proceed tocheckout" Three possibilities exist at present. The page the user is directed to next is dependant on which page they were on when they clicked to access the cart. */ //if returning user is changing cart details after clicking "proceed to checkout" if (isset($_SESSION['cus_id'])) { echo "<form method=\"post\" action=\"checkout2.php\">"; } //if new user is changing cart details before clicking "proceed to checkout" elseif (isset($_SESSION['new_user_form'])) { echo "<form method=\"post\" action=\"checknew.php\">"; } //if any user is changing cart details before clicking "proceed to checkout" else { echo "<form method=\"post\" action=\"checkout.php\">"; } ?> <input type="submit" name="submit" value="Proceed to Checkout"> <!--passes value causing $_SESSION['shopper'] is set to true at appropriate page--> <input type="hidden" name="via_cart"> </form> <br /> <a href="products.php"></a></div> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
claire Posted June 20, 2007 Author Share Posted June 20, 2007 also so my add prod page is having the same problem <?php session_id(); session_start(); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Home</title> <link href="main.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!--use to move the whole content--> body { margin-top: 0px; margin-bottom:20px; } #box2 #prodlist .proddiv { } .style1 {color: #000000} .style3 {color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; } .style5 {font-family: Geneva, Arial, Helvetica, sans-serif} .style6 {font-family: Verdana, Arial, Helvetica, sans-serif} a { color: #666666; } .style7 {color: #333333} </style> </head> <body><!--start main div - this centers content on the page--> <div id="main"> <!--start header - contains company logo--> <!--end header reminder i moved the php start--> //<?php //connect to the database require_once('connection1.php'); //declare variables and assign them values from form echo "<br />"; $qty =$_POST['qty']; $prodnum =$_POST['prodnum']; //assign the value of the session id to $sess $sess =session_id(); /* add new item to the temporary cart table of the database. This is the table which is queried when you view the contents of your cart */ $query = "INSERT INTO carttemp (sess, quan, prodnum) VALUES ('$sess','$qty', '$prodnum')"; $results = mysql_query($query) or die(mysql_error()); //include the cart.php file in this page include("cart.php"); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
kdreg Posted June 21, 2007 Share Posted June 21, 2007 Just a thought, but since you mention the problem appears on your cart page, could the error be in cart.inc? If so, maybe it would be helpful to post cart.inc here. 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.