Jump to content

Archived

This topic is now archived and is closed to further replies.

ImJustBrndn

Two Error Messages

Recommended Posts

I'm having a problem with some of the code I'm using on my site, I keep getting two errors and can't for the life of me figure out how to fix them, any help would be greatly greatly appreciated.

[b]Error 1[/b]

When I try to insert a code to show the amount of items in my shopping cart I get the following error.

[code] Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/t/h/e/theperk/html/index.php:6) in /home/content/t/h/e/theperk/html/index.php on line 57

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/h/e/theperk/html/index.php:6) in /home/content/t/h/e/theperk/html/index.php on line 57[/code]

Page Coding (Where I Want To Insert It)
[code]<!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>Go Ape Shirts - The only shirts endorsed by the man in the yellow hat.</title>
<style type="text/css">
<!--
body {
margin-left: 00px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(bg2.jpg);
}
.style7 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
}
.style9 {font-size: x-small}
a:link {
color: #543B14;
}
a:hover {
color: #D08B54;
}
.style11 {font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; }
.style15 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: medium;
}
.style16 {font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
a:visited {
color: #543B14;
}
a:active {
color: #543B14;
}
-->
</style></head>

<body>
<table width="750" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <?php include 'header.php'; ?>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
        </tr>
      <tr>
        <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="75%" height="38"><img src="new_button.jpg" width="145" height="25" /></td>
            <td width="25%"><div align="center"><a href="cart.php" target="_self"><img src="shoppingcart.gif" width="120" height="29" border="0" /></a></div></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="2"><img src="divider_dot.jpg" width="750" height="5" /></td>
      </tr>
      <tr>
        <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td width="33%"><div align="center">
                  <p><a href="products/007/"><img src="products/007/frontpage.gif" width="216" height="144" border="0" /></a><br />
                      <span class="style7"><strong><a href="products/007/">Oh Nooo  </a></strong><br />
                        <span class="style9">by<a href="about.php"> Justin Schrader  </a></span></span></p>
                  </div></td>
                <td width="34%"><div align="center"><a href="products/008/"><img src="products/008/frontpage.gif" width="216" height="144" border="0" /></a><br />
                  <span class="style7"><strong><a href="products/008/">Bad Day At The Office </a></strong><br />
                        <span class="style9">by <a href="about.php">Erik Varusio </a></span></span></div></td>
                <td width="33%"><div align="center"><a href="products/009/"><img src="products/009/frontpage.gif" width="216" height="144" border="0" /></a><br />
                  <span class="style7"><strong><a href="products/009/">Love Is Blind </a></strong><br />
                        <span class="style9">by<a href="about.php"> John Mitchell </a><a href="about/johnmitchell.php"></a></span></span></div></td>
              </tr>

            </table></td>
            </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
         
          <tr>
            <td><img src="news_button.jpg" width="205" height="25" /></td>
          </tr>
          <tr>
            <td><img src="divider_dot.jpg" width="750" height="5" /></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="8%" rowspan="4">&nbsp;</td>
                <td width="92%">&nbsp;</td>
                </tr>
              <tr>
                <td><img src="news_header_30aug06.jpg" width="274" height="41" /></td>
              </tr>
              <tr>
                <td><blockquote>
                  <p><span class="style11">by <a href="http://www.goapeshirts.com">GoApeShirts</a> on <a href="http://www.goapeshirts.com/news.php">Wednesday, August 30th, 2006<br />
                    </a><span class="style15"><br />
                  </span></span> <span class="style7">Welcome to the new Go Ape Shirts website. The new site has a lot of great features and a great new design. Be sure to check out our THREE new shirts printed this week, and as a little surprise we have HOODIES! The weather is getting a little cooler, so be sure to bundle yourself up in a Boo Boo Walker Hoodie. </span></p>
                </blockquote></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><img src="news_header_16aug06.jpg" width="223" height="41" /></td>
                </tr>
              <tr>
                <td>&nbsp;</td>
                <td><blockquote>
                  <p><span class="style11">by <a href="http://www.goapeshirts.com">GoApeShirts</a> on <a href="http://www.goapeshirts.com/news.php">Monday, August 7th, 2006<br />
                    </a><span class="style15"><br />
                      </span></span> <span class="style7">I will be out of town August 8-14.  I am not sure if I will be able to answer  e-mails.  Any orders placed while I am gone will go out the 16th.  Also, keep an  eye out for 3 new designs coming out in a few weeks.  You can join the  newsletter up above so you can be notified via email when they are released.</span></p>
                  </blockquote></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><img src="divider_dot.jpg" width="750" height="5" /></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr>
                <?php include 'footer.php'; ?>
                </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>


</body>


</html>
[/code]

Code To Insert
[code]<?

session_start();

// If no sessions has been started $_SESSION["cart"] equals null, thus showing the message no items.
if (!isset($_SESSION["cart"])) {
$_SESSION["cart"] = NULL;
}

$itemcount = count($_SESSION["cart"]);
echo "You have <b>".$itemcount."</b> item(s) in your basket.";

?>[/code]


[b]Error 2[/b]

I'm trying to create a coupon system for my shopping cart where if the right word is forwarded from a form on the previos page it deducts 3.00 from the totalvalue. Well if I let the process run I get nothing, but if I echo out the values I either get the price as it is without the discount or just the discount itself (-3.00) as the total. Can someone see what I'm doing wrong.

[code]<?php
  $coupon = $_POST['coupon'];
  $totalvalue = $_POST['totalvalue'];
if ($coupon == "monkey") {

$finalvalue = $totalvalue - 3.00;

} else {

echo "<td colspan=\"5\"><center><p>Unknown Coupon</p></center></td>";

}
?>[/code]

Again, I know this is a big post, but thanks for taking a look and possibly helping.

Brandon

Share this post


Link to post
Share on other sites
For the session_start() error

session_start() HAS to be line 1 of your code
BEFORE the <doctype> and <html>

2nd Problem
Try adding this

echo "Total Value is ".$_POST["total_value"];
To see if that is coming up with anything

Share this post


Link to post
Share on other sites
Thanks for the fast help. The first error is fixed, but the second one when I echo out totalvalue it displays the right amount, and when I do the coupon code it only shows -3. For some reason if I echo the totalvalue it shows up just fine, but if I input the coupon code I only get that -3 like it can't display the totalvalue right in the statement. I've been messing with this for hours and can't get it right.

Brandon

Share this post


Link to post
Share on other sites
Try this somewhere

[code]
<?php
$totalvalue = $_POST["totalvalue"];
echo $totalvalue."<br />\n";
$finalvalue = ($totalvalue - 3.00);
echo $finalvalue;
?>

<form method="post" action="">
<input type="text" name="totalvalue" />
<input type="submit" value="Test" />
</form>

?>
[/code]

Just to check everything is parsing

If you enter 5 in the form
then you should have
5
2

shown above the form

Share this post


Link to post
Share on other sites

×

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.