Jump to content

Index problem


Tranceprofile

Recommended Posts

Hi,

 

I have a problem on my index, there is something wrong in my script but cant figure out what.

 

This is the error code:

Parse error: syntax error, unexpected '<' in /home7/esolarch/public_html/new/index.php on line 45

 

Here is my index.php code:

 

<?php
session_start(); // Must start session first thing
$toplinks = "";
if (isset($_SESSION['id'])) {
// Put stored session variables into local php variable
    $userid = $_SESSION['id'];
    $username = $_SESSION['username'];
$toplinks = '<a href="member_profile.php?id=' . $userid . '">' . $username . '</a> • 
<a href="member_account.php">Account</a> • <a href="cart.php">Cart</a> • 
<a href="logout.php">Log Out</a>';
} else {
$toplinks = '<a href="join_form.php">Register</a> • <a href="login.php">Login</a>';
}
?>
<?php 
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php 
// Run a select query to get my letest 6 items
// Connect to the MySQL database  
include "storescripts/connect_to_mysql.php"; 
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){ 
             $id = $row["id"];
		 $product_name = $row["product_name"];
		 $price = $row["price"];
		 $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
		 $dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
        <tr>
          <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a></td>
          <td width="83%" valign="top">' . $product_name . '<br />
            $' . $price . '<br />
            <a href="product.php?id=' . $id . '">View Product Details</a></td>
        </tr>
      </table>';
    }
} else {
$dynamicList = "We have no products listed in our store yet";
}
mysql_close();
<!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=utf-8" />
<title>Store Home Page</title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body class="Type">
<div align="center" id="mainWrapper">
  <?php include_once("template_header.php");?>
  <div id="pageContent">
  <table width="100%" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td width="28%" valign="top"><h3 class="Type"><?php echo $toplinks; ?></h3></td>
    <td width="72%" valign="top"><h3><br />
      </h3>
      <p><br />
      </p></td>
    </tr>
  <tr>
    <td valign="top"><h3> </h3></td>
    <td valign="top"> </td>
    </tr>
  </table>

  </div>
  <?php include_once("template_footer.php");?>
</div>
</body>
</html>

 

Greetings,

 

Mitch  :D

Link to comment
Share on other sites

 

I changed my "Login | Register" script now to my header.

I will get this error code above my index.php page ( http://www.esolarcharger.com/new/index.php )

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home7/esolarch/public_html/new/index.php:44) in /home7/esolarch/public_html/new/template_header.php on line 2

 

Here is the code of my header:

 

<?php
session_start(); // Must start session first thing
$toplinks = "";
if (isset($_SESSION['id'])) {
// Put stored session variables into local php variable
    $userid = $_SESSION['id'];
    $username = $_SESSION['username'];
$toplinks = '<a href="member_profile.php?id=' . $userid . '">' . $username . '</a> • 
<a href="member_account.php">Account</a> • <a href="cart.php">Cart</a> • 
<a href="logout.php">Log Out</a>';
} else {
$toplinks = '<a href="join_form.php">Register</a> • <a href="login.php">Login</a>';
}
?>
<style type="text/css">
<!--
-->
</style>
<div id="pageHeader"><table width="100%" border="0" cellspacing="0" cellpadding="12">
  <tr>
    <td width="32%" height="88"><a href="http://www.esolarcharger.com/new/index.php"><img src="http://www.esolarcharger.com/new/style/Logo2.png" alt="Logo" width="285" height="97" border="0" /></a></td>
    <td width="68%" align="right"><?php echo $toplinks; ?> </td>
  </tr>
  <tr>
    <td colspan="2"><a href="index.php"><img src="style/home.png" width="65" height="32" border="0" alt="Home_but" /></a> <a href="#"><img src="style/Products.png" width="65" height="32" border="0" alt="Products" /></a> <a href="#"><img src="style/About us.png" width="65" height="32" border="0" alt="About_us" /></a> <a href="#"><img src="style/Contact.png" width="65" height="32" border="0" alt="Contact" /></a></td>
    </tr>
  </table>
</div>

Link to comment
Share on other sites

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home7/esolarch/public_html/new/index.php:44) in /home7/esolarch/public_html/new/template_header.php on line 2

 

That's the problem. Your output has already started on line 44, you can't send headers after you already have output unless you are buffering.

 

Read the sticky: http://www.phpfreaks.com/forums/index.php?topic=37442.0

Link to comment
Share on other sites

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.